mercredi 25 avril 2018

Laravel Validation Only Validate Regex if Field Not Empty

my form have youtube_url field, its not required..
but if user fill this field, i must validate the url using regex..

'youtube_video' => [
    'regex:/(http:\/\/|https:\/\/|)(www.)?(youtu(be\.com|\.be))\/(video\/|embed\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(\&\S+)?/'
],

the regex works well, but its throw error if field is not fill (empty) .
how can validate only when user fill the field.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire