Completed
Push — master ( 4f572b...bf1620 )
by Andrii
13:33
created

UsernameValidator::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace hiapi\validators;
4
5
use yii\validators\RegularExpressionValidator;
6
7
/**
8
 * Class UsernameValidator validates username
9
 * TODO: allow emails also?
10
 *
11
 * @author Andrii Vasyliev <[email protected]>
12
 */
13
class UsernameValidator extends RegularExpressionValidator
14
{
15
    public $pattern = '/^[a-z][a-z0-9_]{2,31}$/';
16
17
    public function init()
18
    {
19
        parent::init();
20
21
        $this->message = 'Value is not a valid username';
22
    }
23
}
24