mardi 9 mars 2021

How to exclude Phone number and URL in string with Validation Laravel?

I want to validate a "title" field which does not include a phone number or url. I have tried with regexes and it only works if I type a phone number or url alone

For exemple:

0617859654 --> work, the validation fail

but

test 0617859654 -> do not work, validation does not detect the phone number

here is my code:

$validator = Validator::make($request->all(), [
            'titre' => 'not_regex:/^([0-9\s\-\+\(\)]*)$/|not_regex:/^https:\/\/\w+(\.\w+)*(:[0-9]+)?\/?$/|not_regex:/^http:\/\/\w+(\.\w+)*(:[0-9]+)?\/?$/',
        ]);

the validation therefore does not work totally, how I can prevent the validation if a phone number or a url is in my title field ?

Thanks !



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3vhmQXZ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire