-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat: [Validation] add method to get the validated data #7420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I'd like to hear the reason for adding this method. |
Security enhancement. |
Let's say the script receives data, some of which do not need to be validated. |
This method is intended for input validation like validation for HTML form. |
For me, currently develop upload batch by excel and will return callback failed excel with marker like Upload:
Callback:
I think this function can use for this case and combine failed validation |
Added the docs. |
]; | ||
|
||
if ($validation->run($data)) { | ||
$validatedData = $validation->getValidated(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example is fine, but I would like to ask you to add an example that will cover controller validation (with the $this->validate() method). This is the place where this method is the most valuable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a plan to add a method to get validated data in Controller
, and update all sample code with $this->validate()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think need a separate method in the controller for this, though.
Since we can get the errors via $this->validator->getErrors()
, I see no problem with getting validated data the same way, via $this->validator->getValidated()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. Thank you for opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #7425
Description
Validation::getValidated()
Checklist: