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