framework
framework copied to clipboard
[Proposal] Validator should add a rule may call 'exist validation'
When I add 'required' rule, Validator will check the field even it's not exists. If I did not add it, Validator will not check the field when it is empty.
Is there anyway to 'set required rule when field exists' so that I can check empty and validate when it exists ?
http://laravel.com/docs/validation#conditionally-adding-rules
You need to use sometimes.
'sometimes|required'
You got that, I'm sorry for my careless.