CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.7 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.7
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
      • Validator
    • Network
      • Email
      • Http
    • Routing
      • Filter
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • CakeValidationRule
  • CakeValidationSet

Class CakeValidationRule

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

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

  • $_passedOptions protected
    array
    Holds passed in options
  • $_recordExists protected
    boolean
    Holds whether the record being validated exists in datasource or not
  • $_rule protected
    mixed
    Validation method
  • $_ruleParams protected
    array
    Validation method arguments
  • $_valid protected
    mixed
    Whether the field passed this validation rule
  • $allowEmpty public
    boolean
    The 'allowEmpty' key
  • $last public
    boolean
    The 'last' key
  • $message public
    string
    The 'message' key
  • $on public
    string
    The 'on' key
  • $required public
    mixed
    The 'required' key
  • $rule public
    mixed
    The 'rule' key

Method Summary

  • __construct() public
    Constructor
  • _addValidatorProps() protected
    Sets the rule properties from the rule entry in validate
  • _getPropertiesArray() protected
    Gets an array with the rule properties
  • _parseRule() protected
    Parses the rule and sets the rule and ruleParams
  • checkEmpty() public
    Checks if the allowEmpty key applies
  • checkRequired() public
    Checks whether the field failed the field should be present validation
  • getOptions() public
    Returns passed options for this rule
  • getValidationResult() public
    Gets the validation error message
  • isEmptyAllowed() public
    Returns whether the field can be left blank according to this rule
  • isLast() public

    Returns whether this rule should break validation process for associated field after it fails

  • isRequired() public
    Checks if the field is required according to the required property
  • isUpdate() public

    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)

  • isValid() public
    Checks if the rule is valid
  • process() public
    Dispatches the validation rule to the given validator method
  • reset() public

    Resets internal state for this rule, by default it will become valid and it will set isUpdate() to false

  • skip() public
    Checks 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
array

_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
boolean

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
boolean

getOptions() public ¶

getOptions( string|integer $key )

Returns passed options for this rule

Parameters
string|integer $key
Array index
Returns
array|null

getValidationResult() public ¶

getValidationResult( )

Gets the validation error message

Returns
string

isEmptyAllowed() public ¶

isEmptyAllowed( )

Returns whether the field can be left blank according to this rule

Returns
boolean

isLast() public ¶

isLast( )

Returns whether this rule should break validation process for associated field after it fails

Returns
boolean

isRequired() public ¶

isRequired( )

Checks if the field is required according to the required property

Returns
boolean

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
boolean

isValid() public ¶

isValid( )

Checks if the rule is valid

Returns
boolean

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
boolean
True if the rule could be dispatched, false otherwise

reset() public ¶

reset( )

Resets internal state for this rule, by default it will become valid and it will set isUpdate() to false

skip() public ¶

skip( )

Checks if the validation rule should be skipped

Returns
boolean
True if the ValidationRule can be skipped

Properties detail

$_passedOptions ¶

protected array

Holds passed in options

array()

$_recordExists ¶

protected boolean

Holds whether the record being validated exists in datasource or not

false

$_rule ¶

protected mixed

Validation method

null

$_ruleParams ¶

protected array

Validation method arguments

array()

$_valid ¶

protected mixed

Whether the field passed this validation rule

true

$allowEmpty ¶

public boolean

The 'allowEmpty' key

null

$last ¶

public boolean

The 'last' key

true

$message ¶

public string

The 'message' key

null

$on ¶

public string

The 'on' key

null

$required ¶

public mixed

The 'required' key

null

$rule ¶

public mixed

The 'rule' key

'blank'
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs