-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
I tried to ensure the validity of an embedded object via a form type by adding a valid constraint.
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('publication', new PublicationType(), array(
'constraints' => array(new \Symfony\Component\Validator\Constraints\Valid())
));
}
The problem is that the ConstraintValidatorFactory can't check the constraint on form submission because it tries to instantiate a ValidValidator which doesn't exist.
I'm not sure whether a ValidValidator class is nonsense(1) (as far as I see, the *Validator classes are responsible for the actual validation) but it would be nice to be able to define the valid validation rule in that context, too.
(1) I thought about writing one, but I'm not sure whether there's a single source to retrieve the constraints from. As far as I see, there's at least the validation.yml, annotations in the classes and maybe even constraints defined in the form types.
array (size=4)
'type' => int 1
'message' => string 'Class 'Symfony\Component\Validator\Constraints\ValidValidator' not found' (length=72)
'file' => string '/Users/macbookdata/NetBeansProjects/DTAMetadata/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Validator/ConstraintValidatorFactory.php' (length=146)
'line' => int 71