mirror of
https://github.com/Respect/Validation.git
synced 2026-03-15 06:45:44 +01:00
I ran the `bin/console spdx --fix` with different strategies for different files. For most of the core classes, since they've been drastically rebuilt, I've run it with the `git-blame` strategy, for for the `src/Validators`, in which the API changed completely but the logic remains the same, I use the `git-log` strategy.
38 lines
1.2 KiB
Markdown
38 lines
1.2 KiB
Markdown
<!--
|
|
SPDX-License-Identifier: MIT
|
|
SPDX-FileCopyrightText: (c) Respect Project Contributors
|
|
SPDX-FileContributor: Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
SPDX-FileContributor: Emmerson Siqueira <emmersonsiqueira@gmail.com>
|
|
SPDX-FileContributor: Henrique Moody <henriquemoody@gmail.com>
|
|
-->
|
|
|
|
# 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](http://php.net/datetime.formats)
|
|
that can be parsed by PHP
|
|
|
|
Below you can see some examples:
|
|
|
|
```php
|
|
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
|
|
```
|