From cab63ca0d586caed47bafd00e4f5d7ef19fcbf58 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Wed, 17 Apr 2013 18:32:20 +0200 Subject: [PATCH] Documented that the Optional and Required constraints were moved to the Symfony\Component\Validator\Constraints\ namespace --- reference/constraints/Collection.rst | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/reference/constraints/Collection.rst b/reference/constraints/Collection.rst index 9fd0c1160c0..84f2238821f 100644 --- a/reference/constraints/Collection.rst +++ b/reference/constraints/Collection.rst @@ -166,6 +166,10 @@ from the ``$personalData`` property, no validation error would occur. .. versionadded:: 2.1 The ``Required`` and ``Optional`` constraints are new to Symfony 2.1. +.. versionadded:: 2.3 + The ``Required`` and ``Optional`` constraints were moved to the namespace + ``Symfony\Component\Validator\Constraints\`` in Symfony 2.3. + Required and Optional Field Constraints ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -191,8 +195,8 @@ field is optional but must be a valid email if supplied, you can do the followin /** * @Assert\Collection( * fields={ - * "personal_email" = @Assert\Collection\Required({@Assert\NotBlank, @Assert\Email}), - * "alternate_email" = @Assert\Collection\Optional({@Assert\Email}), + * "personal_email" = @Assert\Required({@Assert\NotBlank, @Assert\Email}), + * "alternate_email" = @Assert\Optional(@Assert\Email), * } * ) */ @@ -217,8 +221,8 @@ field is optional but must be a valid email if supplied, you can do the followin { $metadata->addPropertyConstraint('profileData', new Assert\Collection(array( 'fields' => array( - 'personal_email' => new Assert\Collection\Required(array(new Assert\NotBlank(), new Assert\Email())), - 'alternate_email' => new Assert\Collection\Optional(array(new Assert\Email())), + 'personal_email' => new Assert\Required(array(new Assert\NotBlank(), new Assert\Email())), + 'alternate_email' => new Assert\Optional(new Assert\Email()), ), ))); }