[[+content_image]]
I
I
ImPuuLsE2016-02-04 11:17:25
Yii
ImPuuLsE, 2016-02-04 11:17:25

Why doesn't rule validation work with match in Yii2?

Hello! there is the following in the model validation rules:

[['title'], 'match', 'pattern' => '/[^\w\d\s,]/u', 'message' => 'В названии могут быть использованы только запятые.'],

But for some reason, it still skips both question and exclamation marks, periods.

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
S
Sergey, 2016-02-04
@ImPuuLsE

Try like this'not' => true, 'pattern' => '/[\w\d\s,]/u'

D
dimabdc, 2016-02-04
@dimabdc

remove the ^ sign from []

Matches any character except for an a, b or c
/[^abc]+/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question