ValidationSet object. Holds all validation rules for a field and exposes methods to dynamically add or remove validation rules
bool|string|callable
Denotes if a field is allowed to be empty
\Cake\Validation\ValidationRule[]
Holds the ValidationRule objects
bool|string|callable
Denotes whether the fieldname key must be present in data array
add(string $name, mixed $rule)
Sets a ValidationRule $rule with a $name
$set ->add('notBlank', ['rule' => 'notBlank']) ->add('inRange', ['rule' => ['between', 4, 10])
string
$name The name under which the rule should be set
\Cake\Validation\ValidationRule|array
$rule The validation rule to be set
$this
allowEmpty(mixed $allowEmpty)
Sets whether a field value is allowed to be empty.
bool|string|callable
$allowEmpty Valid values are true, false, 'create', 'update' or a callable.
$this
count()
Returns the number of rules in this set
int
getIterator()
Returns an iterator for each of the rules to be applied
\Cake\Validation\ValidationRule[]
isEmptyAllowed()
Returns whether or not a field can be left empty.
bool|string|callable
isPresenceRequired()
Returns whether or not a field can be left out.
bool|string|callable
offsetExists(mixed $index)
Returns whether an index exists in the rule set
string
$index name of the rule
bool
offsetGet(mixed $index)
Returns a rule object by its index
string
$index name of the rule
\Cake\Validation\ValidationRule
offsetSet(mixed $index, mixed $rule)
Sets or replace a validation rule
string
$index name of the rule
\Cake\Validation\ValidationRule|array
$rule Rule to add to $index
offsetUnset(mixed $index)
Unsets a validation rule
string
$index name of the rule
remove(string $name)
Removes a validation rule from the set
$set ->remove('notBlank') ->remove('inRange')
string
$name The name under which the rule should be unset
$this
requirePresence(mixed $validatePresent)
Sets whether a field is required to be present in data array.
bool|string|callable
$validatePresent Valid values are true, false, 'create', 'update' or a callable.
$this
rule(string $name)
Gets a rule for a given name if exists
string
$name The name under which the rule is set.
\Cake\Validation\ValidationRule|null
rules()
Returns all rules for this validation set
\Cake\Validation\ValidationRule[]
Denotes if a field is allowed to be empty
bool|string|callable
Holds the ValidationRule objects
\Cake\Validation\ValidationRule[]
Denotes whether the fieldname key must be present in data array
bool|string|callable
© 2005–present 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/4.1/class-Cake.Validation.ValidationSet.html