$data = array( 'user_name' => 'infomaniac', 'user_email' => '
[email protected]', 'user_password_new' => '123456', 'user_password_repeat' => '123456', ); $v = new Validator($data); $v->addRule('username', function ($field, $value, array $params) { // 2 to 64 alphanumeric characters of any case $pattern = '/^[a-z\d]{2,64}$/i'; return preg_match($pattern, $value); }, 'is invalid because it does not contain 2 to 64 alphanumeric characters'); $v->rule('required', ['user_name', 'user_password_new']); $v->rule('username', ['user_name'])->label('Username'); $v->rule('email', ['user_email']); $v->rule('equals', ['user_password_new'], 'user_password_repeat'); $v->rule('length', ['user_password_new'], 6); 17 Sunday 06 October 13