Class CakeValidationRule
CakeValidationRule object. Represents a validation method, error message and rules for applying such method to a field.
Link: http://book.cakephp.org/2.0/en/data-validation.html
Copyright: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
License: MIT License
Location: Cake/Model/Validator/CakeValidationRule.php
Properties summary
- 
			$_passedOptionsprotectedarrayHolds passed in options
- 
			$_recordExistsprotectedbooleanHolds whether the record being validated exists in datasource or not
- 
			$_ruleprotectedmixedValidation method
- 
			$_ruleParamsprotectedarrayValidation method arguments
- 
			$_validprotectedmixedWhether the field passed this validation rule
- 
			$allowEmptypublicbooleanThe 'allowEmpty' key
- 
			$lastpublicbooleanThe 'last' key
- 
			$messagepublicstringThe 'message' key
- 
			$onpublicstringThe 'on' key
- 
			$requiredpublicmixedThe 'required' key
- 
			$rulepublicmixedThe 'rule' key
Method Summary
- 
			__construct() publicConstructor
- 
			_addValidatorProps() protectedSets the rule properties from the rule entry in validate
- 
			_getPropertiesArray() protectedGets an array with the rule properties
- 
			_parseRule() protectedParses the rule and sets the rule and ruleParams
- 
			checkEmpty() publicChecks if the allowEmpty key applies
- 
			checkRequired() publicChecks whether the field failed thefield should be presentvalidation
- 
			getOptions() publicReturns passed options for this rule
- 
			getValidationResult() publicGets the validation error message
- 
			isEmptyAllowed() publicReturns whether the field can be left blank according to this rule
- 
			isLast() publicReturns whether this rule should break validation process for associated field after it fails 
- 
			isRequired() publicChecks if the field is required according to therequiredproperty
- 
			isUpdate() publicSets the recordExists configuration value for this rule, ir refers to whether the model record it is validating exists exists in the collection or not (create or update operation) 
- 
			isValid() publicChecks if the rule is valid
- 
			process() publicDispatches the validation rule to the given validator method
- 
			reset() publicResets internal state for this rule, by default it will become valid and it will set isUpdate() to false 
- 
			skip() publicChecks if the validation rule should be skipped
Method Detail
__construct() public ¶
__construct( array $validator = array() )
Constructor
Parameters
- array $validator optional array()
- [optional] The validator properties
_addValidatorProps() protected ¶
_addValidatorProps( array $validator = array() )
Sets the rule properties from the rule entry in validate
Parameters
- array $validator optional array()
- [optional]
_getPropertiesArray() protected ¶
_getPropertiesArray( )
Gets an array with the rule properties
Returns
_parseRule() protected ¶
_parseRule( string $field , array $data )
Parses the rule and sets the rule and ruleParams
Parameters
- string $field
- Field name
- array $data
- $data Data array
checkEmpty() public ¶
checkEmpty( string $field , array $data )
Checks if the allowEmpty key applies
Parameters
- string $field
- Field name
- array $data
- $data data to check rule against
Returns
checkRequired() public ¶
checkRequired( string $field , array $data )
Checks whether the field failed the field should be present validation
Parameters
- string $field
- Field name
- array $data
- $data Data to check rule against
Returns
getOptions() public ¶
getOptions( string|integer $key )
Returns passed options for this rule
Parameters
- string|integer $key
- Array index
Returns
getValidationResult() public ¶
getValidationResult( )
Gets the validation error message
Returns
isEmptyAllowed() public ¶
isEmptyAllowed( )
Returns whether the field can be left blank according to this rule
Returns
isLast() public ¶
isLast( )
Returns whether this rule should break validation process for associated field after it fails
Returns
isRequired() public ¶
isRequired( )
Checks if the field is required according to the required property
Returns
isUpdate() public ¶
isUpdate( boolean $exists = null )
Sets the recordExists configuration value for this rule, ir refers to whether the model record it is validating exists exists in the collection or not (create or update operation)
If called with no parameters it will return whether this rule is configured for update operations or not.
Parameters
- boolean $exists optional null
- Boolean to indicate if records exists
Returns
process() public ¶
process( string $field , array $data , array $methods )
Dispatches the validation rule to the given validator method
Parameters
- string $field
- Field name
- array $data
- $data Data array
- array $methods
- $methods Methods list
Returns
True if the rule could be dispatched, false otherwise
Properties detail
$_recordExists ¶
Holds whether the record being validated exists in datasource or not
false
			