Class CakeValidationRule
CakeValidationRule object. Represents a validation method, error message and rules for applying such method to a field.
Copyright: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
License: MIT License
Link: http://book.cakephp.org/2.0/en/data-validation.html
Located at Cake/Model/Validator/CakeValidationRule.php
Method Detail
__constructsource public
__construct( array $validator array() )
Constructor
Parameters
- array
$validator
optional array() - [optional] The validator properties
_addValidatorPropssource protected
_addValidatorProps( array $validator array() )
Sets the rule properties from the rule entry in validate
Parameters
- array
$validator
optional array() - [optional]
_getPropertiesArraysource protected
_getPropertiesArray( )
Gets an array with the rule properties
Returns
array
array
_parseRulesource 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
checkEmptysource 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
boolean
bool
checkRequiredsource 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
boolean
bool
getOptionssource public
getOptions( string|integer $key )
Returns passed options for this rule
Parameters
- string|integer
$key
- Array index
Returns
array|null
array|null
getValidationResultsource public
getValidationResult( )
Gets the validation error message
Returns
string
string
isEmptyAllowedsource public
isEmptyAllowed( )
Returns whether the field can be left blank according to this rule
Returns
boolean
bool
isLastsource public
isLast( )
Returns whether this rule should break validation process for associated field after it fails
Returns
boolean
bool
isRequiredsource public
isRequired( )
Checks if the field is required according to the required
property
Returns
boolean
bool
isUpdatesource 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
boolean
bool
processsource 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
boolean
True if the rule could be dispatched, false otherwise
resetsource public
reset( )
Resets internal state for this rule, by default it will become valid and it will set isUpdate() to false
skipsource public
skip( )
Checks if the validation rule should be skipped
Returns
boolean
True if the ValidationRule can be skipped
Properties summary
© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
http://api.cakephp.org/2.7/class-CakeValidationRule.html