Skip to content

Commit d3c3136

Browse files
committed
Deprecate age-related rules
Signed-off-by: Henrique Moody <[email protected]>
1 parent cf03f8a commit d3c3136

32 files changed

+107
-428
lines changed

docs/02-feature-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Is possible to validate its properties in a single chain:
4242

4343
```php
4444
$userValidator = v::property('name', v::stringType()->length(1, 32))
45-
->property('birthdate', v::date()->minAge(18));
45+
->property('birthdate', v::dateTimeDiff(v::greaterThanOrEqual(18), 'years'));
4646

4747
$userValidator->validate($user); // true
4848
```

docs/08-list-of-rules-by-category.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@
7878
- [DateTimeDiff](rules/DateTimeDiff.md)
7979
- [LeapDate](rules/LeapDate.md)
8080
- [LeapYear](rules/LeapYear.md)
81-
- [MaxAge](rules/MaxAge.md)
82-
- [MinAge](rules/MinAge.md)
8381
- [Time](rules/Time.md)
8482

8583
## File system
@@ -380,10 +378,8 @@
380378
- [Luhn](rules/Luhn.md)
381379
- [MacAddress](rules/MacAddress.md)
382380
- [Max](rules/Max.md)
383-
- [MaxAge](rules/MaxAge.md)
384381
- [Mimetype](rules/Mimetype.md)
385382
- [Min](rules/Min.md)
386-
- [MinAge](rules/MinAge.md)
387383
- [Multiple](rules/Multiple.md)
388384
- [Negative](rules/Negative.md)
389385
- [NfeAccessKey](rules/NfeAccessKey.md)

docs/rules/Date.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,4 @@ See also:
4848
- [DateTimeDiff](DateTimeDiff.md)
4949
- [LeapDate](LeapDate.md)
5050
- [LeapYear](LeapYear.md)
51-
- [MaxAge](MaxAge.md)
52-
- [MinAge](MinAge.md)
5351
- [Time](Time.md)

docs/rules/DateTime.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ See also:
7777
- [DateTimeDiff](DateTimeDiff.md)
7878
- [LeapDate](LeapDate.md)
7979
- [LeapYear](LeapYear.md)
80-
- [MinAge](MinAge.md)
8180
- [Time](Time.md)
8281

8382
[DateTimeImmutable::createFromFormat()]: https://www.php.net/datetimeimmutable.createfromformat

docs/rules/GreaterThanOrEqual.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,4 @@ See also:
3838
- [LessThan](LessThan.md)
3939
- [LessThanOrEqual](LessThanOrEqual.md)
4040
- [Max](Max.md)
41-
- [MaxAge](MaxAge.md)
4241
- [Min](Min.md)
43-
- [MinAge](MinAge.md)

docs/rules/LessThanOrEqual.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,4 @@ See also:
3838
- [Length](Length.md)
3939
- [LessThan](LessThan.md)
4040
- [Max](Max.md)
41-
- [MaxAge](MaxAge.md)
4241
- [Min](Min.md)
43-
- [MinAge](MinAge.md)

docs/rules/MaxAge.md

Lines changed: 0 additions & 42 deletions
This file was deleted.

docs/rules/MinAge.md

Lines changed: 0 additions & 43 deletions
This file was deleted.

library/Factory.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Respect\Validation\Message\Parameter\Stringify;
1919
use Respect\Validation\Message\Parameter\Trans;
2020
use Respect\Validation\Transformers\Aliases;
21+
use Respect\Validation\Transformers\DeprecatedAge;
2122
use Respect\Validation\Transformers\DeprecatedAttribute;
2223
use Respect\Validation\Transformers\DeprecatedKey;
2324
use Respect\Validation\Transformers\DeprecatedKeyNested;
@@ -60,7 +61,9 @@ public function __construct()
6061
new DeprecatedKey(
6162
new DeprecatedKeyValue(
6263
new DeprecatedMinAndMax(
63-
new DeprecatedKeyNested(new DeprecatedLength(new DeprecatedType(new Aliases(new Prefix()))))
64+
new DeprecatedAge(
65+
new DeprecatedKeyNested(new DeprecatedLength(new DeprecatedType(new Aliases(new Prefix()))))
66+
)
6467
)
6568
)
6669
)

library/Mixins/ChainedKey.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,10 @@ public function keyMacAddress(int|string $key): ChainedValidator;
228228

229229
public function keyMax(int|string $key, Validatable $rule): ChainedValidator;
230230

231-
public function keyMaxAge(int|string $key, int $age, ?string $format = null): ChainedValidator;
232-
233231
public function keyMimetype(int|string $key, string $mimetype): ChainedValidator;
234232

235233
public function keyMin(int|string $key, Validatable $rule): ChainedValidator;
236234

237-
public function keyMinAge(int|string $key, int $age, ?string $format = null): ChainedValidator;
238-
239235
public function keyMultiple(int|string $key, int $multipleOf): ChainedValidator;
240236

241237
public function keyNegative(int|string $key): ChainedValidator;

0 commit comments

Comments
 (0)