CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.8 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.8
      • 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

Namespaces

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Command
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
      • Retry
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
      • Middleware
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
      • Client
        • Adapter
        • Auth
      • Cookie
      • Exception
      • Middleware
      • Session
    • I18n
      • Formatter
      • Middleware
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Middleware
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • RulesProvider
  • Validation
  • ValidationRule
  • ValidationSet
  • Validator

Interfaces

  • ValidatableInterface
  • ValidatorAwareInterface

Traits

  • ValidatorAwareTrait

Class ValidationSet

ValidationSet object. Holds all validation rules for a field and exposes methods to dynamically add or remove validation rules

Cake\Validation\ValidationSet implements ArrayAccess, IteratorAggregate, Countable
Namespace: Cake\Validation
Location: Validation/ValidationSet.php

Properties summary

  • $_allowEmpty protected
    boolean|string|callable
    Denotes if a field is allowed to be empty
  • $_rules protected
    Cake\Validation\ValidationRule[]
    Holds the ValidationRule objects
  • $_validatePresent protected
    boolean|string|callable
    Denotes whether the fieldname key must be present in data array

Method Summary

  • add() public
    Sets a ValidationRule $rule with a $name
  • allowEmpty() public
    Sets whether a field value is allowed to be empty.
  • count() public
    Returns the number of rules in this set
  • getIterator() public
    Returns an iterator for each of the rules to be applied
  • isEmptyAllowed() public
    Sets whether a field value is allowed to be empty.
  • isPresenceRequired() public
    Sets whether a field is required to be present in data array.
  • offsetExists() public
    Returns whether an index exists in the rule set
  • offsetGet() public
    Returns a rule object by its index
  • offsetSet() public
    Sets or replace a validation rule
  • offsetUnset() public
    Unsets a validation rule
  • remove() public
    Removes a validation rule from the set
  • requirePresence() public
    Sets whether a field is required to be present in data array.
  • rule() public
    Gets a rule for a given name if exists
  • rules() public
    Returns all rules for this validation set

Method Detail

add() public ¶

add( string $name , Cake\Validation\ValidationRule|array $rule )

Sets a ValidationRule $rule with a $name

Example:

$set
         ->add('notBlank', ['rule' => 'notBlank'])
         ->add('inRange', ['rule' => ['between', 4, 10])
Parameters
string $name
The name under which the rule should be set
Cake\Validation\ValidationRule|array $rule
The validation rule to be set
Returns

$this

allowEmpty() public ¶

allowEmpty( boolean|string|callable $allowEmpty )

Sets whether a field value is allowed to be empty.

Parameters
boolean|string|callable $allowEmpty

Valid values are true, false, 'create', 'update' or a callable.

Returns

$this

count() public ¶

count( )

Returns the number of rules in this set

Returns
integer
Implementation of
Countable::count()

getIterator() public ¶

getIterator( )

Returns an iterator for each of the rules to be applied

Returns
ArrayIterator
Implementation of
IteratorAggregate::getIterator()

isEmptyAllowed() public ¶

isEmptyAllowed( boolean|string|callable|null $allowEmpty = null )

Sets whether a field value is allowed to be empty.

If no argument is passed the currently set allowEmpty value will be returned.

Parameters
boolean|string|callable|null $allowEmpty optional null

Deprecated since 3.6.0 ValidationSet::isEmptyAllowed() is deprecated as a setter. Use ValidationSet::allowEmpty() instead.

Returns
boolean|string|callable

isPresenceRequired() public ¶

isPresenceRequired( boolean|string|callable|null $validatePresent = null )

Sets whether a field is required to be present in data array.

If no argument is passed the currently set validatePresent value will be returned.

Parameters
boolean|string|callable|null $validatePresent optional null

Deprecated since 3.6.0 ValidationSet::isPresenceRequired() is deprecated as a setter Use ValidationSet::requirePresence() instead.

Returns
boolean|string|callable

offsetExists() public ¶

offsetExists( string $index )

Returns whether an index exists in the rule set

Parameters
string $index
name of the rule
Returns
boolean
Implementation of
ArrayAccess::offsetExists()

offsetGet() public ¶

offsetGet( string $index )

Returns a rule object by its index

Parameters
string $index
name of the rule
Returns
Cake\Validation\ValidationRule
Implementation of
ArrayAccess::offsetGet()

offsetSet() public ¶

offsetSet( string $index , Cake\Validation\ValidationRule|array $rule )

Sets or replace a validation rule

Parameters
string $index
name of the rule
Cake\Validation\ValidationRule|array $rule
Rule to add to $index
Implementation of
ArrayAccess::offsetSet()

offsetUnset() public ¶

offsetUnset( string $index )

Unsets a validation rule

Parameters
string $index
name of the rule
Implementation of
ArrayAccess::offsetUnset()

remove() public ¶

remove( string $name )

Removes a validation rule from the set

Example:

$set
         ->remove('notBlank')
         ->remove('inRange')
Parameters
string $name
The name under which the rule should be unset
Returns

$this

requirePresence() public ¶

requirePresence( boolean|string|callable $validatePresent )

Sets whether a field is required to be present in data array.

Parameters
boolean|string|callable $validatePresent
Valid values are true, false, 'create', 'update' or a callable.
Returns

$this

rule() public ¶

rule( string $name )

Gets a rule for a given name if exists

Parameters
string $name
The name under which the rule is set.
Returns
Cake\Validation\ValidationRule|null

rules() public ¶

rules( )

Returns all rules for this validation set

Returns
Cake\Validation\ValidationRule[]

Properties detail

$_allowEmpty ¶

protected boolean|string|callable

Denotes if a field is allowed to be empty

false

$_rules ¶

protected Cake\Validation\ValidationRule[]

Holds the ValidationRule objects

[]

$_validatePresent ¶

protected boolean|string|callable

Denotes whether the fieldname key must be present in data array

false
Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs