src/Model/UserValidationTrait.php
public function validationUserName(Validator $validator) {
		$validator->setProvider('userTable', $this->_table);

		$validator->add($this->_field('username'), [
			'notBlank' => [
				'rule' => 'notBlank',
				'message' => __d('user_tools', 'An username is required.')
			],
			'length' => [
				'rule' => ['lengthBetween', 3, 32],
				'message' => __d('user_tools', 'The username must be between 3 and 32 characters.')
			],
			'unique' => [
				'rule' => ['validateUnique', ['scope' => 'username']],
				'provider' => 'userTable',
				'message' => __d('user_tools', 'The username is already in use.')
			],
			'alphaNumeric' => [
				'rule' => 'alphaNumeric',
				'message' => __d('user_tools', 'The username must be alpha numeric.')
			]
		]);

		return $validator;
	}
public function validationUserName(Validator $validator) {
		$validator->setProvider('userTable', $this->_table);

		$validator->add($this->_field('username'), [
			'notBlank' => [
				'rule' => 'notBlank',
				'message' => __d('user_tools', 'An username is required.')
			],
			'length' => [
				'rule' => ['lengthBetween', 3, 32],
				'message' => __d('user_tools', 'The username must be between 3 and 32 characters.')
			],
			'unique' => [
				'rule' => ['validateUnique', ['scope' => 'username']],
				'provider' => 'userTable',
				'message' => __d('user_tools', 'The username is already in use.')
			],
			'alphaNumeric' => [
				'rule' => 'alphaNumeric',
				'message' => __d('user_tools', 'The username must be alpha numeric.')
			]
		]);

		return $validator;
	}
public function validationUserName ( Validator $ validator ) { $ validator -> setProvider ( 'userTable' , $ this -> _table ) ; $ validator -> add ( $ this -> _field ( 'username' ) , [ 'notBlank' => [ 'rule' => 'notBlank' , 'message' => __d ( 'user_tools' , 'An username is required.' ) ] , 'length' => [ 'rule' => [ 'lengthBetween' , 3 , 32 ] , 'message' => __d ( 'user_tools' , 'The username must be between 3 and 32 characters.' ) ] , 'unique' => [ 'rule' => [ 'validateUnique' , [ 'scope' => 'username' ] ] , 'provider' => 'userTable' , 'message' => __d ( 'user_tools' , 'The username is already in use.' ) ] , 'alphaNumeric' => [ 'rule' => 'alphaNumeric' , 'message' => __d ( 'user_tools' , 'The username must be alpha numeric.' ) ] ] ) ; return $ validator ; }
Validates the username field.

Override it as needed to change the rules for only that field.

@param \Cake\Validation\Validator $validator Validator
@return \Cake\Validation\Validator
Validates the username field .