This repository has been archived by the owner on Jan 31, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explode Introduction, Supported Options and Basic Usage documentation
- Loading branch information
1 parent
010084d
commit 79a9c85
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Explode Validator | ||
|
||
`Zend\Validator\Explode` executes a validator for each item exploded. | ||
|
||
## Supported options | ||
|
||
The following options are supported for `Zend\Validator\Explode`: | ||
|
||
- `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. | ||
- `validator`: Sets the validator that will be executed on each exploded item. | ||
|
||
## Basic usage | ||
|
||
To validate if every item in an array is into a certain haystack: | ||
|
||
```php | ||
$inArrayValidator = new Zend\Validator\InArray([ | ||
'haystack' => [1, 2, 3, 4, 5, 6] | ||
]); | ||
|
||
$explodeValidator = new Zend\Validator\Explode([ | ||
'validator' => $inArrayValidator | ||
]); | ||
|
||
$value = [1, 4, 6, 8]; | ||
$return = $valid->isValid($value); | ||
// returns false | ||
``` | ||
|
||
The above example returns `true` if all $value items are between 1 and 6. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters