lundi 23 novembre 2015

Laravel different validation rule if another field exists

I pass work and mobile phones to my form. I want to make sure that they are different. My validation rules are:

'form_data.mobile_phone' => 'max:255|different:form_data.work_phone',
'form_data.work_phone' => 'max:255',

However, when I pass only mobile phone I got validation error that mobile phone should be different from work phone. I tried to put sometimes rule with the same effect.

How to check that mobile phone and work phone are different only if both are present?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire