public function validation()
    {
        $validator = new Validation();
        $validator->add(
            'email',
            new Email([
                'field' => 'email',
                'required' => true,
            ])
        );

        $validator->add(
            'displayname',
            new PresenceOf([
                'field' => 'displayname',
                'required' => true,
            ])
        );

        $validator->add(
            'displayname',
            new Regex([
                'field' => 'displayname',
                'message' => _('Please use alphanumerics only.'),
                'pattern' => '/^[A-Za-z0-9_.-]{1,16}$/',
            ])
        );

        // Unique values
        $validator->add(
            'email',
            new Uniqueness([
                'field' => 'email',
                'message' => _('This email already has an account.'),
            ])
        );

        $validator->add(
            'displayname',
            new Uniqueness([
                'field' => 'displayname',
                'message' => _('The username is already taken.'),
            ])
        );

        return $this->validate($validator);
    }
public function validation()
    {
        $validator = new Validation();
        $validator->add(
            'email',
            new Email([
                'field' => 'email',
                'required' => true,
            ])
        );

        $validator->add(
            'displayname',
            new PresenceOf([
                'field' => 'displayname',
                'required' => true,
            ])
        );

        $validator->add(
            'displayname',
            new Regex([
                'field' => 'displayname',
                'message' => _('Please use alphanumerics only.'),
                'pattern' => '/^[A-Za-z0-9_.-]{1,16}$/',
            ])
        );

        // Unique values
        $validator->add(
            'email',
            new Uniqueness([
                'field' => 'email',
                'message' => _('This email already has an account.'),
            ])
        );

        $validator->add(
            'displayname',
            new Uniqueness([
                'field' => 'displayname',
                'message' => _('The username is already taken.'),
            ])
        );

        return $this->validate($validator);
    }
public function validation ( ) { $ validator = new Validation ( ) ; $ validator -> add ( 'email' , new Email ( [ 'field' => 'email' , 'required' => true , ] ) ) ; $ validator -> add ( 'displayname' , new PresenceOf ( [ 'field' => 'displayname' , 'required' => true , ] ) ) ; $ validator -> add ( 'displayname' , new Regex ( [ 'field' => 'displayname' , 'message' => _ ( 'Please use alphanumerics only.' ) , 'pattern' => '/^[A-Za-z0-9_.-]{1,16}$/' , ] ) ) ; // Unique values $ validator -> add ( 'email' , new Uniqueness ( [ 'field' => 'email' , 'message' => _ ( 'This email already has an account.' ) , ] ) ) ; $ validator -> add ( 'displayname' , new Uniqueness ( [ 'field' => 'displayname' , 'message' => _ ( 'The username is already taken.' ) , ] ) ) ; return $ this -> validate ( $ validator ) ; }
Validations and business logic
Validations and business logic