Grav\Plugin\AdminPlugin::validate PHP Method

validate() protected method

- 'user' for username format and username availability. - 'password1' for password format - 'password2' for equality to password1
protected validate ( string $type, string $value, string $extra = '' ) : boolean
$type string The field type
$value string The field value
$extra string Any extra value required
return boolean
    protected function validate($type, $value, $extra = '')
    {
        switch ($type) {
            case 'username_format':
                if (!preg_match('/^[a-z0-9_-]{3,16}$/', $value)) {
                    return false;
                }
                return true;
            case 'password1':
                if (!preg_match('/(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{8,}/', $value)) {
                    return false;
                }
                return true;
            case 'password2':
                if (strcmp($value, $extra)) {
                    return false;
                }
                return true;
        }
        return false;
    }