respect-validation/docs/rules/Not.md
Henrique Moody a3c197f600
Handle names via the Named rule
Because of how the validation engine works now [1], there's no reason to
keep adding names to each rule. Instead, create a single rule that
handles naming rules with a few other accessories. This change is not
necessarily simple, but it shrinks the `Rule` interface, and it's more
aligned with how the library works right now.

Personally, I think this API is much more straightforward than the
`setName()` method, as it's way more explicit about which rule we're
naming. Because of this change, the behaviour changed slightly, but it's
for the best.

Because of this change, I managed to remove a lot of code, but
unfortunately, it's quite a big-bang commit. It would be too complicated
to make it atomic since names are an intrinsic part of the library.

[1]: 238f2d506a
2024-12-26 23:10:19 +01:00

892 B

Not

  • Not(Rule $rule)

Negates any rule.

v::not(v::ip())->isValid('foo'); // true

In the sample above, validator returns true because 'foo' isn't an IP Address.

You can negate complex, grouped or chained validators as well:

v::not(v::intVal()->positive())->isValid(-1.5); // true

Each other validation has custom messages for negated rules.

Templates

Template placeholders

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

Categorization

  • Core
  • Conditions
  • Nesting

Changelog

Version Description
0.3.9 Created

See also: