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|callable
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
allowEmpty( boolean|string|callable $allowEmpty )
Sets whether a field value is allowed to be empty.
$allowEmpty
Valid values are true, false, 'create', 'update' or a callable.
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 Deprecated since 3.6.0 ValidationSet::isEmptyAllowed() is deprecated as a setter. Use ValidationSet::allowEmpty() instead.
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.
$validatePresent
optional null Deprecated since 3.6.0 ValidationSet::isPresenceRequired() is deprecated as a setter Use ValidationSet::requirePresence() instead.
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
requirePresence( boolean|string|callable $validatePresent )
Sets whether a field is required to be present in data array.
$validatePresent
rule( string $name )
Gets a rule for a given name if exists
$name
Cake\Validation\ValidationRule
|nullrules( )
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|callable
Denotes whether the fieldname key must be present in data array
false
© 2005–2018 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.6/class-Cake.Validation.ValidationSet.html