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 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
License: License (http://www.opensource.org/licenses/mit-license.php)
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 whethere 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 wheter 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 interal 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( $field , $data )
Parses the rule and sets the rule and ruleParams
checkEmpty() public ¶
checkEmpty( array $field , $data )
Checks if the allowEmpty key applies
Parameters
- array $field
- $data data to check rule against
- $data
Returns
checkRequired() public ¶
checkRequired( array $field , $data )
Checks whether the field failed the field should be present validation
Parameters
- array $field
- $data data to check rule against
- $data
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 whethere 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( $exists = null )
Sets the recordExists configuration value for this rule, ir refers to wheter 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.
Returns
process() public ¶
process( $field , $data , $methods )
Dispatches the validation rule to the given validator method
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
			