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

Commit b327118

Browse files
committed
Merge branch 'hotfix/209'
Close #209 Fixes #171 Fixes #137
2 parents 9e75f58 + 224d55e commit b327118

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ All notable changes to this project will be documented in this file, in reverse
1818
to the IBAN validator for performing SEPA validation against Croatia and San
1919
Marino.
2020

21+
- [#209](https://github.com/zendframework/zend-validator/pull/209) adds
22+
documentation for the `Explode` validator.
23+
2124
### Changed
2225

2326
- Nothing.

doc/book/validators/explode.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Explode Validator
2+
3+
`Zend\Validator\Explode` executes a validator for each item exploded from an
4+
array.
5+
6+
## Supported options
7+
8+
The following options are supported for `Zend\Validator\Explode`:
9+
10+
- `valueDelimiter`: Defines the delimiter used to explode values from an array.
11+
It defaults to `,`. If the given value is an array, this option isn't used.
12+
- `validator`: Sets the validator that will be executed on each exploded item.
13+
This may be a validator instance, or a validator service name.
14+
15+
## Basic usage
16+
17+
To validate if every item in an array is in a specified haystack:
18+
19+
```php
20+
$inArrayValidator = new Zend\Validator\InArray([
21+
'haystack' => [1, 2, 3, 4, 5, 6],
22+
]);
23+
24+
$explodeValidator = new Zend\Validator\Explode([
25+
'validator' => $inArrayValidator
26+
]);
27+
28+
$explodeValidator->isValid([1, 4, 6]); // returns true
29+
$explodeValidator->isValid([1, 4, 6, 8]); // returns false
30+
```
31+
32+
## Exploding strings
33+
34+
To validate if every e-mail in a string is contained in a list of names:
35+
36+
```php
37+
$inEmailListValidator = new Zend\Validator\InArray([
38+
39+
]);
40+
41+
$explodeValidator = new Zend\Validator\Explode([
42+
'validator' => $inEmailListValidator,
43+
'valueDelimiter' => ','
44+
]);
45+
46+
$explodeValidator->isValid('[email protected],[email protected]'); // returns true
47+
$explodeValidator->isValid('[email protected],[email protected]'); // returns false
48+
```

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pages:
1717
- "Db\\RecordExists and Db\\NoRecordExists": validators/db.md
1818
- Digits: validators/digits.md
1919
- EmailAddress: validators/email-address.md
20+
- Explode: validators/explode.md
2021
- GreaterThan: validators/greater-than.md
2122
- Hex: validators/hex.md
2223
- Hostname: validators/hostname.md

0 commit comments

Comments
 (0)