respect-validation/docs/rules/Min.md
Henrique Moody 9eafe52252
Refactor the Length rule
Currently, the Length rule does multiple things, yet it's limited.
Because it does many things, it's also confusing. Turning the Length
rule into a transformation allows for way more flexibility and clarity.

The syntax becomes more verbose, but I can solve that later by creating
a Transformer enables creating rules with the "length" as a prefix.

While making this change, I also removed the support for counting
objects and integers. I find that way too confusing.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-03-19 15:38:29 +01:00

1.2 KiB

Min

  • Min(Validatable $rule)

Validates the minimum value of the input against a given rule.

v::min(v::equals(10))->validate([10, 20, 30]); // true

v::min(v::between('a', 'c'))->validate(['b', 'd', 'f']); // true

v::min(v::greaterThan(new DateTime('yesterday')))
        ->validate([new DateTime('today'), new DateTime('tomorrow')]); // true

v::min(v::lessThan(3))->validate([4, 8, 12]); // false

Note

This rule uses IterableType and NotEmpty internally. If an input is non-iterable or empty, the validation will fail.

Categorization

  • Comparisons
  • Transformations

Changelog

Version Description
3.0.0 Became a transformation
2.0.0 Became always inclusive
1.0.0 Became inclusive by default
0.3.9 Created

See also: