Closed
Description
Description
OptionConfigurator would have new method checkConstraints(Constraint[] $constraints)
. User can set validation constraints that will be checked by OptionResolver.
Similar like form fields can have constraints.
In OptionsResolver would be new method addConstraints(string $option, Constraint[] $constraints)
and resolve() would be created Validator a validate all options.
Example
$resolver = new OptionsResolver();
$resolver->define('email')
->required()
->allowedTypes('string')
->checkConstraints([
new Assert\NotBlank(),
new Assert\Email(),
]);
$resolver->resolve(['email' => 'invalidEmail']);
// resolve would throw InvalidOptionsException with ConstraintViolationListInterface