Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit ce94e3c

Browse files
committed
chore: improved documentation rules data
1 parent 42178c6 commit ce94e3c

File tree

7 files changed

+81
-12
lines changed

7 files changed

+81
-12
lines changed

docs/03-rules-all.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,25 @@
22

33
Validates every element of an `array` with a given set of rules.
44

5+
```php
6+
/**
7+
* @var RuleInterface[] $constraints
8+
*/
9+
All(
10+
array $constraints,
11+
string $message = 'At "{{ key }}": {{ message }}'
12+
);
13+
```
14+
515
## Basic Usage
616

717
```php
8-
Validator::all([Validator::greatarThan(1), Validator::lessThan(10)])->validate([4, 5, 6]); // true
9-
Validator::all([Validator::greaterThan(1)->lessThan(10)])->validate([4, 5, 6]); // true
18+
// One rule per array element
19+
Validator::all([Validator::notBlank(), Validator::greaterThan(1), Validator::lessThan(10)])->validate([4, 5, 6]); // true
20+
Validator::all([Validator::notBlank(), Validator::greaterThan(1), Validator::lessThan(10)])->validate([4, 5, 20]); // false
1021

11-
Validator::all([Validator::greatarThan(1), Validator::lessThan(10)])->validate([4, 5, 20]); // false
22+
// Multiple rules per array element
23+
Validator::all([Validator::notBlank()->greaterThan(1)->lessThan(10)])->validate([4, 5, 6]); // true
1224
```
1325

1426
> **Note**
@@ -31,7 +43,6 @@ Each element must implement a `RuleInterface`, so it is possible to use a single
3143
type: `string` default: `At "{{ key }}": {{ message }}`
3244

3345
Message that will be shown if at least one element of an array is invalid according to the given `constraints`.
34-
Check the [Custom Messages]() section for more information.
3546

3647
```php
3748
Validator::all([Validator::notBlank()])->assert([1, 2, ''], 'Test');

docs/03-rules-greater-than-or-equal.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,25 @@
33
Validates that a value is greater than or equal to another value.
44
Can compare between strings, numbers and dates.
55

6+
```php
7+
GreaterThanOrEqual(
8+
mixed $constraint,
9+
string $message = 'The "{{ name }}" value should be greater than or equal to "{{ constraint }}", "{{ value }}" given.'
10+
);
11+
```
12+
613
## Basic Usage
714

815
```php
916
Validator::greaterThanOrEqual(10)->validate(20); // true
1017
Validator::greaterThanOrEqual(10)->validate(10); // true
18+
1119
Validator::greaterThanOrEqual(1.5)->validate(2.5); // true
1220
Validator::greaterThanOrEqual(1.5)->validate(1.5); // true
21+
1322
Validator::greaterThanOrEqual('alpha')->validate('beta'); // true
1423
Validator::greaterThanOrEqual('alpha')->validate('alpha'); // true
24+
1525
Validator::greaterThanOrEqual(new DateTime('today'))->validate(new DateTime('tomorrow')); // true
1626
Validator::greaterThanOrEqual(new DateTime('today'))->validate(new DateTime('today')); // true
1727
```
@@ -36,8 +46,7 @@ Can be a `string`, `int`, `float` or `DateTimeInterface` object.
3646

3747
type: `string` default: `The "{{ name }}" value should be greater than or equal to "{{ constraint }}", "{{ value }}" given.`
3848

39-
Message that will be shown if the value is not greater than or equal to the constraint value.
40-
Check the [Custom Messages]() section for more information.
49+
Message that will be shown if the value is not greater than or equal to the constraint value.
4150

4251
The following parameters are available:
4352

docs/03-rules-greater-than.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,27 @@
33
Validates that a value is greater than another value.
44
Can compare between strings, numbers and dates.
55

6+
```php
7+
GreaterThan(
8+
mixed $constraint,
9+
string $message = 'The "{{ name }}" value should be greater than "{{ constraint }}", "{{ value }}" given.'
10+
);
11+
```
12+
613
## Basic Usage
714

815
```php
916
Validator::greaterThan(10)->validate(20); // true
17+
Validator::greaterThan(10)->validate(10); // false
18+
1019
Validator::greaterThan(1.5)->validate(2.5); // true
20+
Validator::greaterThan(1.5)->validate(1.5); // false
21+
1122
Validator::greaterThan('alpha')->validate('beta'); // true
23+
Validator::greaterThan('alpha')->validate('alpha'); // false
24+
1225
Validator::greaterThan(new DateTime('today'))->validate(new DateTime('tomorrow')); // true
26+
Validator::greaterThan(new DateTime('today'))->validate(new DateTime('today')); // false
1327
```
1428

1529
> **Note**
@@ -32,8 +46,7 @@ Can be a `string`, `int`, `float` or `DateTimeInterface` object.
3246

3347
type: `string` default: `The "{{ name }}" value should be greater than "{{ constraint }}", "{{ value }}" given.`
3448

35-
Message that will be shown if the value is not greater than the constraint value.
36-
Check the [Custom Messages]() section for more information.
49+
Message that will be shown if the value is not greater than the constraint value.
3750

3851
The following parameters are available:
3952

docs/03-rules-less-than-or-equal.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,25 @@
33
Validates that a value is less than or equal to another value.
44
Can compare between strings, numbers and dates.
55

6+
```php
7+
LessThanOrEqual(
8+
mixed $constraint,
9+
string $message = 'The "{{ name }}" value should be less than or equal to "{{ constraint }}", "{{ value }}" given.'
10+
);
11+
```
12+
613
## Basic Usage
714

815
```php
916
Validator::lessThanOrEqual(20)->validate(10); // true
1017
Validator::lessThanOrEqual(10)->validate(10); // true
18+
1119
Validator::lessThanOrEqual(2.5)->validate(1.5); // true
1220
Validator::lessThanOrEqual(1.5)->validate(1.5); // true
21+
1322
Validator::lessThanOrEqual('beta')->validate('alpha'); // true
1423
Validator::lessThanOrEqual('alpha')->validate('alpha'); // true
24+
1525
Validator::lessThanOrEqual(new DateTime('today'))->validate(new DateTime('yesterday')); // true
1626
Validator::lessThanOrEqual(new DateTime('today'))->validate(new DateTime('today')); // true
1727
```
@@ -37,7 +47,6 @@ Can be a `string`, `int`, `float` or `DateTimeInterface` object.
3747
type: `string` default: `The "{{ name }}" value should be less than or equal to "{{ constraint }}", "{{ value }}" given.`
3848

3949
Message that will be shown if the value is not less than or equal to the constraint value.
40-
Check the [Custom Messages]() section for more information.
4150

4251
The following parameters are available:
4352

docs/03-rules-less-than.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,27 @@
33
Validates that a value is less than another value.
44
Can compare between strings, numbers and dates.
55

6+
```php
7+
LessThan(
8+
mixed $constraint,
9+
string $message = 'The "{{ name }}" value should be less than "{{ constraint }}", "{{ value }}" given.'
10+
);
11+
```
12+
613
## Basic Usage
714

815
```php
916
Validator::lessThan(20)->validate(10); // true
17+
Validator::lessThan(20)->validate(20); // false
18+
1019
Validator::lessThan(2.5)->validate(1.5); // true
20+
Validator::lessThan(2.5)->validate(2.5); // false
21+
1122
Validator::lessThan('beta')->validate('alpha'); // true
23+
Validator::lessThan('beta')->validate('beta'); // false
24+
1225
Validator::lessThan(new DateTime('today'))->validate(new DateTime('yesterday')); // true
26+
Validator::lessThan(new DateTime('today'))->validate(new DateTime('today')); // false
1327
```
1428

1529
> **Note**
@@ -33,7 +47,6 @@ Can be a `string`, `int`, `float` or `DateTimeInterface` object.
3347
type: `string` default: `The "{{ name }}" value should be less than "{{ constraint }}", "{{ value }}" given.`
3448

3549
Message that will be shown if the value is not less than the constraint value.
36-
Check the [Custom Messages]() section for more information.
3750

3851
The following parameters are available:
3952

docs/03-rules-not-blank.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
Validates that a value is not equal to a blank string, blank array, `false` or `null`.
44

5+
```php
6+
NotBlank(
7+
?callable $normalizer = null,
8+
string $message = 'The "{{ name }}" value should not be blank, "{{ value }}" given.'
9+
);
10+
```
11+
512
## Basic Usage
613

714
Bellow are the only cases where the rule will fail, everything else is considered valid
@@ -36,8 +43,7 @@ Validator::notBlank(normalizer: fn($value) => trim($value))->validate(' '); // f
3643

3744
type: `string` default: `The "{{ name }}" value should not be blank, "{{ value }}" given.`
3845

39-
Message that will be shown if the value is blank.
40-
Check the [Custom Messages]() section for more information.
46+
Message that will be shown if the value is blank.
4147

4248
The following parameters are available:
4349

docs/03-rules-range.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
Validates that a value is between a minimum and maximum value.
44
Can compare between strings, numbers and dates.
55

6+
```php
7+
Range(
8+
mixed $minConstraint,
9+
mixed $maxConstraint,
10+
string $message = 'The "{{ name }}" value should be between "{{ minConstraint }}" and "{{ maxConstraint }}", "{{ value }}" given.'
11+
);
12+
```
13+
614
## Basic Usage
715

816
Values equal to the defined minimum and maximum constraints are considered valid.

0 commit comments

Comments
 (0)