2
votes

I am using laravel 4 validation required_with to validate either one field should be provided and its working fine

but I need only one field to be entered by user e.g user filled both field then it should show error that either field1 or field2 should be provided but not both

Is there a way to do this by using Laravel's default validation or I need to create custom rule for that?

1
Maybe using required_without and required_with but i think a custom validator will be the better choice.Ezequiel Moreno

1 Answers

0
votes

You are right. None of the builtin validation rules allows you making sure that only one of the fields are set.

Custom validator is way to go.