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

Commit 6d1b253

Browse files
committed
docs: fixed EachKey example
1 parent 96d4ef4 commit 6d1b253

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

docs/03-rules_each-key.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## EachKey
22

3-
Validates every key of an `array` or object implementing `\Traversable` with a given set of rules.
3+
Validates every key of an `array`, or object implementing `\Traversable`, with a given set of rules.
44

55
```php
66
EachKey(
@@ -12,8 +12,13 @@ EachKey(
1212
## Basic Usage
1313

1414
```php
15-
Validator::eachKey(Validator::notBlank()->type('string'))->validate(['red' => '#f00', 'green' => '#0f0']); // true
16-
Validator::eachKey(Validator::notBlank()->type('string'))->validate(['red' => '#f00', 1 => '#0f0']); // false
15+
Validator::eachKey(
16+
Validator::notBlank()->type('string')
17+
)->validate(['red' => '#f00', 'green' => '#0f0']); // true
18+
19+
Validator::eachKey(
20+
Validator::notBlank()->type('string')
21+
)->validate(['red' => '#f00', 1 => '#0f0']); // false
1722
```
1823

1924
> [!NOTE]
@@ -34,7 +39,9 @@ type: `string` default: `Invalid key: {{ message }}`
3439
Message that will be shown if at least one input value key is invalid according to the given `validator`.
3540

3641
```php
37-
Validator::eachKey(Validator::notBlank())->assert(['red' => '#f00', 1 => '#0f0'], 'color');
42+
Validator::eachKey(
43+
Validator::type('string')
44+
)->assert(['red' => '#f00', 1 => '#0f0'], 'color');
3845
// Throws: Invalid key: The color key value should be of type "string", 1 given.
3946
```
4047

docs/03-rules_each-value.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ EachValue(
1212
## Basic Usage
1313

1414
```php
15-
Validator::eachValue(Validator::notBlank()->greaterThan(1)->lessThan(10))->validate([4, 5, 6]); // true
16-
Validator::eachValue(Validator::notBlank()->greaterThan(1)->lessThan(10))->validate([4, 5, 20]); // false
15+
Validator::eachValue(
16+
Validator::notBlank()->greaterThan(1)->lessThan(10)
17+
)->validate([4, 5, 6]); // true
18+
19+
Validator::eachValue(
20+
Validator::notBlank()->greaterThan(1)->lessThan(10)
21+
)->validate([4, 5, 20]); // false
1722
```
1823

1924
> [!NOTE]
@@ -34,7 +39,9 @@ type: `string` default: `At key "{{ key }}": {{ message }}`
3439
Message that will be shown if at least one input value element is invalid according to the given `validator`.
3540

3641
```php
37-
Validator::eachValue(Validator::notBlank())->assert(['red', 'green', ''], 'color');
42+
Validator::eachValue(
43+
Validator::notBlank()
44+
)->assert(['red', 'green', ''], 'color');
3845
// Throws: At key 2: The color value should not be blank, "" given.
3946
```
4047

0 commit comments

Comments
 (0)