respect-validation/docs/rules/NotUndef.md
Henrique Moody 338c186803
Invert the behaviour of NotBlank
Since we have the ability to use `not` as a prefix, having rules that
start with not becomes a bit inflexible, verbose, and harder to
understand.

This commit will refactor the `NotBlank` rule by inverting its behaviour
and renaming it to `Blank`. Although this is a breaking change, users
will not feel it because "NotBlank" will still be available by using the
`not` prefix followed by the `Blank` rule.
2025-12-27 17:18:30 +01:00

1.7 KiB

NotUndef

  • NotUndef()

Validates if the given input is not optional. By optional we consider null or an empty string ('').

v::notUndef()->isValid(''); // false
v::notUndef()->isValid(null); // false

Other values:

v::notUndef()->isValid([]); // true
v::notUndef()->isValid(' '); // true
v::notUndef()->isValid(0); // true
v::notUndef()->isValid('0'); // true
v::notUndef()->isValid(0); // true
v::notUndef()->isValid('0.0'); // true
v::notUndef()->isValid(false); // true
v::notUndef()->isValid(['']); // true
v::notUndef()->isValid([' ']); // true
v::notUndef()->isValid([0]); // true
v::notUndef()->isValid(['0']); // true
v::notUndef()->isValid([false]); // true
v::notUndef()->isValid([[''), [0]]); // true
v::notUndef()->isValid(new stdClass()); // true

Templates

NotUndef::TEMPLATE_STANDARD

Mode Template
default {{subject}} must be defined
inverted {{subject}} must be undefined

Template placeholders

Placeholder Description
subject The validated input or the custom validator name (if specified).

Categorization

  • Miscellaneous

Changelog

Version Description
3.0.0 Renamed from "NotOptional" to "NotUndef"
1.0.0 Created

See also: