Class CakeValidationRule

CakeValidationRule object. Represents a validation method, error message and rules for applying such method to a field.

Package: Cake\Model\Validator
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

isValidsource public

isValid( )

Checks if the rule is valid

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

$_passedOptionssource

protected array

Holds passed in options

array()

$_recordExistssource

protected boolean

Holds whether the record being validated exists in datasource or not

false

$_rulesource

protected mixed

Validation method

null

$_ruleParamssource

protected array

Validation method arguments

array()

$_validsource

protected mixed

Whether the field passed this validation rule

true

$allowEmptysource

public boolean

The 'allowEmpty' key

null

$lastsource

public boolean

The 'last' key

true

$messagesource

public string

The 'message' key

null

$onsource

public string

The 'on' key

null

$requiredsource

public mixed

The 'required' key

null

$rulesource

public mixed

The 'rule' key

'blank'

© 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