respect-validation/docs/rules/NotEmpty.md
Henrique Moody 634a155c63
Always display the input
The "NotBlank", "NotEmpty", and "NotUndef" rules do not display the
input in all cases and instead displays the string "The value". The
problem with that is that one doesn't see which value was passed, which
is not so useful.

This commit will changes those rules to always display the input. If
someone doesn't want the input to show, they can always set a name for
the rule.
2024-12-22 06:55:21 +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 {{name}} must not be empty
inverted {{name}} must be empty

Template placeholders

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

Categorization

  • Miscellaneous

Changelog

Version Description
0.3.9 Created

See also: