markwilson / symfony2-validator-fields-intersect-not-empty
Constraint to check at least one of the keys exist in an array
Installs: 1 667
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- symfony/validator: 2.2.x
This package is not auto-updated.
Last update: 2021-01-23 09:24:39 UTC
README
Note: currently only works for validator component 2.2.x
Constraint to check if an array contains at least one of the provided keys.
Install
Add markwilson/symfony2-validator-fields-intersect-not-empty
to composer.json requires.
Usage
FieldsIntersectNotEmpty
requires a fields
option which takes an array of keys to search in the validating value.
e.g.
use MarkWilson\Validator\Constraints\FieldsIntersectNotEmpty; use Symfony\Component\Validator\Validation; $constraint = new FieldsIntersectNotEmpty(array('one', 'of', 'these', 'must', 'exist'); $validator = Validation::createValidator(); $value = array('nothing' => true, 'matches' => true); $validator->validateValue($value, $constraint); // invalid $value = array('exist' => true, 'matches' => true); $validator->validateValue($value, $constraint); // valid