masonite
masonite copied to clipboard
Add `bail` validation rule
Is your feature request related to a problem?
It is possible to "stop on first validation failure" in Laravel and it would be great to do the same here in Masonite validation, to avoid writing complex rules with exists or when
https://laravel.com/docs/8.x/validation#stopping-on-first-validation-failure
What do we currently have to do now?
For now it's not possible or we have to write complex rules with exists or when to achieve it.
Describe the solution you'd like
We could maybe do something like:
errors = request.validate({
"age": "bail|numeric|greater_than:18",
})
Here if numeric is failing, greater_than won't be checked (and that's nice else it would raise an error because the input could be not numeric)
Describe alternatives you've considered
There is also the nullable rule, here are more details:
https://github.com/MasoniteFramework/validation/issues/53
Would this be a breaking change ?
- [ ] Yes
Anything else ?
I am totally open for discussion on this !
As a base this PR https://github.com/MasoniteFramework/validation/pull/47/files was trying to implement this.