A
A
Alexander Laikov2017-03-01 17:31:23
Yii
Alexander Laikov, 2017-03-01 17:31:23

How to create validation for symbols?

Good afternoon
How to create a validation rule according to the rule: Name_Firstname?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav, 2017-03-01
@Florens

public function rules()
    {
        return [
            [
                'user_name', 
                'match', 
                'pattern'=>'/^[A-Z][A-Za-z]*_[A-Z][A-Za-z]*$/', 
            ],
        ];
    }

M
Maxim Timofeev, 2017-03-01
@webinar

What is this "Name_Firstname" rule?
In any case, most likely we are talking about a regular expression, then here:
www.yiiframework.com/doc-2.0/guide-tutorial-core-v...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question