mercredi 14 novembre 2018

Laravel not recognize regex contain special character | or ]

trying to check a sentence contains special character | or ] using Laravel/Lumen validation in the controller like as below

'to_address' => 'required|max:200|regex:/^[^(|]~`!%^&*=};:?><’)]*$/',

if I user this validation on my controller, I'm getting the following error

{
    "error": "preg_match(): No ending delimiter '/' found"
}

without | and ] the validation is working correctly.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire