fatima1's avatar

not_regex validation

hi

How to use not_regex for validation i'm using laravel 5.2

 $this->validate($request, [
           'title'  => 'required|not_regex:([0-9])',
]

it give this error

BadMethodCallException in Validator.php line 3321:
Method [validateNotRegex] does not exist.
0 likes
4 replies
bramr94's avatar

Well the not_regex validation rule does not exist in Laravel 5.2. You could use the regex validation rule and don't allow numbers: /^([^0-9]*)$/

fatima1's avatar

@BRAMR94 - oh, thank you. but how to have two regex pattern in one field?

bramr94's avatar
bramr94
Best Answer
Level 2

Maybe this will work?

'title' => [
    'required',
    'regex:/^([^0-9]*)$/',
    'regex:second expression',
],

But it's probably better to combine the two regex patterns.

Please or to participate in this conversation.