framework icon indicating copy to clipboard operation
framework copied to clipboard

[Proposal] Validator should add a rule may call 'exist validation'

Open tinpont opened this issue 12 years ago • 2 comments

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 ?

tinpont avatar Jul 18 '14 06:07 tinpont

http://laravel.com/docs/validation#conditionally-adding-rules

You need to use sometimes.

'sometimes|required'

bworwa avatar Jul 18 '14 13:07 bworwa

You got that, I'm sorry for my careless.

tinpont avatar Jul 18 '14 13:07 tinpont