Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit 9507252

Browse files
Improvements according to pull request review
Improved valueDelimiter description. Fixed array example Added explode string example.
1 parent 79a9c85 commit 9507252

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

doc/book/validators/explode.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
The following options are supported for `Zend\Validator\Explode`:
88

9-
- `valueDelimiter`: Defines the delimiter used to explode the value to an array. It defaults to `,`. If working with an array, this option isn't used.
9+
- `valueDelimiter`: Defines the delimiter used to explode the value to an array. It defaults to `,`. If the given value is an array, this option isn't used.
1010
- `validator`: Sets the validator that will be executed on each exploded item.
1111

1212
## Basic usage
@@ -22,9 +22,24 @@ $explodeValidator = new Zend\Validator\Explode([
2222
'validator' => $inArrayValidator
2323
]);
2424

25-
$value = [1, 4, 6, 8];
26-
$return = $valid->isValid($value);
27-
// returns false
25+
$explodeValidator->isValid([1, 4, 6]); // returns true
26+
$explodeValidator->isValid([1, 4, 6, 8]); // returns false
2827
```
2928

30-
The above example returns `true` if all $value items are between 1 and 6.
29+
## Exploding strings
30+
31+
To validate if every e-mail in an string is into a certain name list:
32+
33+
```php
34+
$inEmailListValidator = new Zend\Validator\InArray([
35+
36+
]);
37+
38+
$explodeValidator = new Zend\Validator\Explode([
39+
'validator' => $inEmailListValidator,
40+
'valueDelimiter' => ','
41+
]);
42+
43+
$explodeValidator->isValid('[email protected],[email protected]'); // returns true
44+
$explodeValidator->isValid('[email protected],[email protected]'); // returns false
45+
```

0 commit comments

Comments
 (0)