feat: [Validation] add method to get the validated data - #7420
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.
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.
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.
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.
Oh, I see. Thank you for opinion.
Description
Validation::getValidated()Checklist: