original_string: public function validationDefault(Validator $validator) {
  		if (!empty($this->validate)) {
  			foreach ($this->validate as $field => $rules) {
  				if (is_int($field)) {
  					$field = $rules;
  					$rules = [];
  				}
  				if (!$rules) {
  					continue;
  
  				}
  				$rules = (array)$rules;
  
  				foreach ($rules as $key => $rule) {
  					if (is_string($rule)) {
  						$ruleArray = ['rule' => $rule];
  						$rules[$rule] = $ruleArray;
  						unset($rules[$key]);
  						$key = $rule;
  						$rule = $ruleArray;
  					}
  
  					if (isset($rule['required'])) {
  						$validator->requirePresence($field, $rule['required']);
  						unset($rules[$key]['required']);
  					}
  					if (isset($rule['allowEmpty'])) {
  						$validator->allowEmpty($field, $rule['allowEmpty']);
  						unset($rules[$key]['allowEmpty']);
  					}
  					if (isset($rule['message'])) {
  						if (is_array($rule['message'])) {
  							$name = array_shift($rule['message']);
  							//$args = array_slice($rule['message'], 1);
  							$args = $this->_translateArgs($rule['message']);
  							$message = __d($this->validationDomain, $name, $args);
  						} else {
  							$message = __d($this->validationDomain, $rule['message']);
  						}
  						$rules[$key]['message'] = $message;
  					}
  
  					if (!empty($rules[$key]['rule']) && ($rules[$key]['rule'] === 'notEmpty' || $rules[$key]['rule'] === ['notEmpty'])) {
  						$rules[$key]['rule'] = 'notBlank';
  					}
  
  					if (!empty($rules[$key]['rule']) && ($rules[$key]['rule'] === 'isUnique' || $rules[$key]['rule'] === ['isUnique'])) {
  						$rules[$key]['rule'] = 'validateUnique';
  						$rules[$key]['provider'] = 'table';
  					}
  				}
  
  				$validator->add($field, $rules);
  			}
  		}
  
  		return $validator;
  	}
code: public function validationDefault(Validator $validator) {
  		if (!empty($this->validate)) {
  			foreach ($this->validate as $field => $rules) {
  				if (is_int($field)) {
  					$field = $rules;
  					$rules = [];
  				}
  				if (!$rules) {
  					continue;
  
  				}
  				$rules = (array)$rules;
  
  				foreach ($rules as $key => $rule) {
  					if (is_string($rule)) {
  						$ruleArray = ['rule' => $rule];
  						$rules[$rule] = $ruleArray;
  						unset($rules[$key]);
  						$key = $rule;
  						$rule = $ruleArray;
  					}
  
  					if (isset($rule['required'])) {
  						$validator->requirePresence($field, $rule['required']);
  						unset($rules[$key]['required']);
  					}
  					if (isset($rule['allowEmpty'])) {
  						$validator->allowEmpty($field, $rule['allowEmpty']);
  						unset($rules[$key]['allowEmpty']);
  					}
  					if (isset($rule['message'])) {
  						if (is_array($rule['message'])) {
  							$name = array_shift($rule['message']);
  							//$args = array_slice($rule['message'], 1);
  							$args = $this->_translateArgs($rule['message']);
  							$message = __d($this->validationDomain, $name, $args);
  						} else {
  							$message = __d($this->validationDomain, $rule['message']);
  						}
  						$rules[$key]['message'] = $message;
  					}
  
  					if (!empty($rules[$key]['rule']) && ($rules[$key]['rule'] === 'notEmpty' || $rules[$key]['rule'] === ['notEmpty'])) {
  						$rules[$key]['rule'] = 'notBlank';
  					}
  
  					if (!empty($rules[$key]['rule']) && ($rules[$key]['rule'] === 'isUnique' || $rules[$key]['rule'] === ['isUnique'])) {
  						$rules[$key]['rule'] = 'validateUnique';
  						$rules[$key]['provider'] = 'table';
  					}
  				}
  
  				$validator->add($field, $rules);
  			}
  		}
  
  		return $validator;
  	}
code_tokens: public function validationDefault ( Validator $ validator ) { if ( ! empty ( $ this -> validate ) ) { foreach ( $ this -> validate as $ field => $ rules ) { if ( is_int ( $ field ) ) { $ field = $ rules ; $ rules = [ ] ; } if ( ! $ rules ) { continue ; } $ rules = ( array ) $ rules ; foreach ( $ rules as $ key => $ rule ) { if ( is_string ( $ rule ) ) { $ ruleArray = [ 'rule' => $ rule ] ; $ rules [ $ rule ] = $ ruleArray ; unset ( $ rules [ $ key ] ) ; $ key = $ rule ; $ rule = $ ruleArray ; } if ( isset ( $ rule [ 'required' ] ) ) { $ validator -> requirePresence ( $ field , $ rule [ 'required' ] ) ; unset ( $ rules [ $ key ] [ 'required' ] ) ; } if ( isset ( $ rule [ 'allowEmpty' ] ) ) { $ validator -> allowEmpty ( $ field , $ rule [ 'allowEmpty' ] ) ; unset ( $ rules [ $ key ] [ 'allowEmpty' ] ) ; } if ( isset ( $ rule [ 'message' ] ) ) { if ( is_array ( $ rule [ 'message' ] ) ) { $ name = array_shift ( $ rule [ 'message' ] ) ; //$args = array_slice($rule['message'], 1); $ args = $ this -> _translateArgs ( $ rule [ 'message' ] ) ; $ message = __d ( $ this -> validationDomain , $ name , $ args ) ; } else { $ message = __d ( $ this -> validationDomain , $ rule [ 'message' ] ) ; } $ rules [ $ key ] [ 'message' ] = $ message ; } if ( ! empty ( $ rules [ $ key ] [ 'rule' ] ) && ( $ rules [ $ key ] [ 'rule' ] === 'notEmpty' || $ rules [ $ key ] [ 'rule' ] === [ 'notEmpty' ] ) ) { $ rules [ $ key ] [ 'rule' ] = 'notBlank' ; } if ( ! empty ( $ rules [ $ key ] [ 'rule' ] ) && ( $ rules [ $ key ] [ 'rule' ] === 'isUnique' || $ rules [ $ key ] [ 'rule' ] === [ 'isUnique' ] ) ) { $ rules [ $ key ] [ 'rule' ] = 'validateUnique' ; $ rules [ $ key ] [ 'provider' ] = 'table' ; } } $ validator -> add ( $ field , $ rules ) ; } } return $ validator ; }
docstring: Shim the 2.x way of validate class properties.
  
  @param \Cake\Validation\Validator $validator
  @return \Cake\Validation\Validator
docstring_tokens: Shim the 2 . x way of validate class properties .