respect-validation/docs/rules/NotEmpty.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.5 KiB

NotEmpty

  • NotEmpty()

Validates wether the given input is not empty. This function also takes whitespace into account, use noWhitespace() if no spaces or linebreaks and other whitespace anywhere in the input is desired.

v::stringType()->notEmpty()->isValid(''); // false

Null values are empty:

v::notEmpty()->isValid(null); // false

Numbers:

v::intVal()->notEmpty()->isValid(0); // false

Empty arrays:

v::arrayVal()->notEmpty()->isValid([]); // false

Whitespace:

v::stringType()->notEmpty()->isValid('        ');  //false
v::stringType()->notEmpty()->isValid("\t \n \r");  //false

Templates

NotEmpty::TEMPLATE_STANDARD

Mode Template
default {{subject}} must not be empty
inverted {{subject}} must be empty

Template placeholders

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

Categorization

  • Miscellaneous

Changelog

Version Description
0.3.9 Created

See also: