Replace isValid() calls with assert()

There's more value on showing how `assert()` displays the validation
messages than simply showing if `isValid()` returns `true` or `false`.

However, that increases the chances of having outdated documentation, so
I created a doc linter that updates the Markdown files with the
correct message.
This commit is contained in:
Henrique Moody 2026-01-06 14:12:06 +01:00
commit d2198dfd01
No known key found for this signature in database
GPG key ID: 221E9281655813A6
165 changed files with 1748 additions and 623 deletions

View file

@ -10,13 +10,20 @@ The `$format` argument should follow PHP's [date()][] function. When the `$forma
[Supported Date and Time Formats][] by PHP (see [strtotime()][]).
```php
v::dateTimeDiff('years', v::equals(7))->isValid('7 years ago'); // true
v::dateTimeDiff('years', v::equals(7))->isValid('7 years ago + 1 minute'); // false
v::dateTimeDiff('years', v::equals(7))->assert('7 years ago');
// → The number of years between now and "7 years ago" must be equal to 7
v::dateTimeDiff('years', v::greaterThan(18), 'd/m/Y')->isValid('09/12/1990'); // true
v::dateTimeDiff('years', v::greaterThan(18), 'd/m/Y')->isValid('09/12/2023'); // false
v::dateTimeDiff('years', v::equals(7))->assert('7 years ago + 1 minute');
// → The number of years between now and "7 years ago + 1 minute" must be equal to 7
v::dateTimeDiff('months', v::between(1, 18))->isValid('5 months ago'); // true
v::dateTimeDiff('years', v::greaterThan(18), 'd/m/Y')->assert('09/12/1990');
// Validation passes successfully
v::dateTimeDiff('years', v::greaterThan(18), 'd/m/Y')->assert('09/12/2023');
// → The number of years between "01/01/2024" and "09/12/2023" must be greater than 18
v::dateTimeDiff('months', v::between(1, 18))->assert('5 months ago');
// Validation passes successfully
```
The supported types are:
@ -70,11 +77,11 @@ Used when the input cannot be parsed with the given format.
The template serves as a prefix to the template of the inner validator.
```php
v::dateTimeDiff('years', v::equals(2))->assert('1 year ago')
// The number of years between now and 1 year ago must be equal to 2
v::dateTimeDiff('years', v::equals(2))->assert('1 year ago');
// The number of years between now and "1 year ago" must be equal to 2
v::not(v::dateTimeDiff('years', v::lessThan(8)))->assert('7 year ago')
// The number of years between now and 7 year ago must not be less than 8
v::not(v::dateTimeDiff('years', v::lessThan(8)))->assert('7 year ago');
// The number of years between now and "7 year ago" must not be less than 8
```
## Template placeholders
@ -94,7 +101,7 @@ When using custom templates, the key must be `dateTimeDiff` + name of the valida
v::dateTimeDiff('years', v::equals(2))->assert('1 year ago', [
'dateTimeDiffEquals' => 'Please enter a date that is 2 years ago'
]);
// Please enter a date that is 2 years ago.
// Please enter a date that is 2 years ago
```
## Categorization