2

Here is what I'm trying to accomplish, I have a form that has a dropdown field of types, lets say type1, type2, type3, and I have a textfield, I want to make the rule for the textfield depend on the type, for example if the type is type1 then the validation rule for the value of the textfield should be 'email' if it is type2 then the validation rule is 'number', etc. I have read the Validation documentation on the Laravel site, I know this section is what I'm trying to accomplish, but I like to keep validation logic separate from the controller, and it doesn't say how to call the sometimes method from within the request class.

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
Tariq Qubti
  • 43
  • 1
  • 6
  • If you want to keep the validation logic separated from the controller use this trait https://github.com/dwightwatson/validating – Claudio King Apr 23 '16 at 12:55
  • Go for custom validation https://laravel.com/docs/5.2/validation#custom-validation-rules – Abhishek Apr 24 '16 at 14:24

0 Answers0