ValidationSet object. Holds all validation rules for a field and exposes methods to dynamically add or remove validation rules
$_allowEmpty
protected boolean|string|callable
$_rules
protected $_validatePresent
protected boolean|string
add( string $name , Cake\Validation\ValidationRule|array $rule )
Sets a ValidationRule $rule with a $name
$set ->add('notBlank', ['rule' => 'notBlank']) ->add('inRange', ['rule' => ['between', 4, 10])
$name
Cake\Validation\ValidationRule
|array $rule
count( )
Returns the number of rules in this set
Countable::count()
getIterator( )
Returns an iterator for each of the rules to be applied
IteratorAggregate::getIterator()
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.
$allowEmpty
optional null Valid values are true, false, 'create', 'update'
isPresenceRequired( boolean|string|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.
$validatePresent
optional null offsetExists( string $index )
Returns whether an index exists in the rule set
$index
ArrayAccess::offsetExists()
offsetGet( string $index )
Returns a rule object by its index
$index
Cake\Validation\ValidationRule
ArrayAccess::offsetGet()
offsetSet( string $index , Cake\Validation\ValidationRule|array $rule )
Sets or replace a validation rule
$index
Cake\Validation\ValidationRule
|array $rule
ArrayAccess::offsetSet()
offsetUnset( string $index )
Unsets a validation rule
$index
ArrayAccess::offsetUnset()
remove( string $name )
Removes a validation rule from the set
$set ->remove('notBlank') ->remove('inRange')
$name
rule( string $name )
Gets a rule for a given name if exists
$name
Cake\Validation\ValidationRule
rules( )
Returns all rules for this validation set
Cake\Validation\ValidationRule[]
protected boolean|string|callable
Denotes if a field is allowed to be empty
false
protected boolean|string
Denotes whether the fieldname key must be present in data array
false
© 2005–2017 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.
https://api.cakephp.org/3.4/class-Cake.Validation.ValidationSet.html