Back to Validation

Falsy

docs/validators/Falsy.md

3.1.11.7 KB
Original Source
<!-- SPDX-License-Identifier: MIT SPDX-FileCopyrightText: (c) Respect Project Contributors SPDX-FileContributor: Alexandre Gomes Gaigalas <[email protected]> SPDX-FileContributor: Henrique Moody <[email protected]> -->

Falsy

  • Falsy()

Validates whether the given input is considered empty or falsy, similar to PHP's empty() function.

We recommend you to check Comparing empty values for more details.

php
v::falsy()->assert('');
// Validation passes successfully

Null values are empty:

php
v::falsy()->assert(null);
// Validation passes successfully

Numbers:

php
v::falsy()->assert(0);
// Validation passes successfully

Empty arrays:

php
v::falsy()->assert([]);
// Validation passes successfully

Templates

Falsy::TEMPLATE_STANDARD

ModeTemplate
default{{subject}} must be falsy
inverted{{subject}} must not be falsy

Template placeholders

PlaceholderDescription
subjectThe validated input or the custom validator name (if specified).

Categorization

  • Miscellaneous

Changelog

VersionDescription
3.0.0Renamed to Falsy and changed the behavior
0.3.9Created as NotEmpty

See Also