I am writing the following code to validate the first and last name in Request class.
public function rules()
{
return [
'FirstName' => 'max:30',
'FirstName.regex' => 'regex:/^[a-zA-Z]+$/',
'LastName' => 'required|min:3|max:30',
'LastName.regex' => 'regex:/^[a-zA-Z]+$/',
];
}
public function messages () {
return [
'FirstName.regex' => 'FirstName can have only chars and numbers.',
'LastName.regex' => 'LastName can have only chars and numbers.',
];
}
If I input FirstName or LastName as Pankaj Garg It's being accepted.
Can u guide, where I am missing the correct code?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire