Closed cednore closed 2 years ago
@mikeerickson Please take care of version bump if above changes are g2g.
Improving to handle nested rules...
@mikeerickson Just pushed the fix for _onlyInputWithRules
function to handle nested rules. Please review.
✨
validated()
methodFixes #307
Description
This PR adds two methods to
Validator
's prototype;validated()
and_onlyInputWithRules()
. Inspired from Laravel's validation concepts.validated()
method will retrieve the input data without the attributes not defined in rules provided. This helps to extract only valid dataset from input and filter out unnecessary or additional attributes from input.While
validated()
throws an error if the validation fails,_onlyInputWithRules()
does the pure job to filter out non-listed-in-rules attributes.validated()
method relies on_onyInputWithRules()
method under the hood.Type of change