respect-validation/docs/comparable-values.md
Alexandre Gomes Gaigalas d9cdc118b2 Introduce REUSE compliance
This commit introduces REUSE compliance by annotating all files
with SPDX information and placing the reused licences in the
LICENSES folder.

We additionally removed the docheader tool which is made obsolete
by this change.

The main LICENSE and copyright text of the project is now not under
my personal name anymore, and it belongs to "The Respect Project
Contributors" instead.

This change restores author names to several files, giving the
appropriate attribution for contributions.
2026-01-21 06:28:11 +00:00

1 KiB

Comparable values

For certain types you can't make comparisons out of the box in PHP but Validation brings support to a few of them.

You can make comparison with the following data types:

  • Countable: any object that implements Countable interface
  • DateTimeInterface
  • Numeric types
  • Single character string
  • Primitive types in general: normal operation comparison made by PHP
  • Time string: date and time format that can be parsed by PHP

Below you can see some examples:

v::greaterThanOrEqual(100)->isValid($collection); // true if it has at least 100 items

v::dateTime()
    ->between(new DateTime('yesterday'), new DateTime('tomorrow'))
    ->isValid(new DateTime('now')); // true

v::numericVal()->lessThanOrEqual(10)->isValid(5); // true

v::stringVal()->between('a', 'f')->isValid('d'); // true

v::dateTime()->between('yesterday', 'tomorrow')->isValid('now'); // true