Skip to content

Commit

Permalink
Update Collection.rst
Browse files Browse the repository at this point in the history
Removed use statements for Required/Optional. Instead use Assert\Collection\Required.
  • Loading branch information
benglass committed Apr 1, 2013
1 parent f826f60 commit 2d4eb95
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions reference/constraints/Collection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,14 @@ field is optional but must be a valid email if supplied, you can do the followin
namespace Acme\BlogBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Constraints\Collection\Optional;
use Symfony\Component\Validator\Constraints\Collection\Required;
class Author
{
/**
* @Assert\Collection(
* fields={
* "personal_email" = @Required({@Assert\NotBlank, @Assert\Email}),
* "alternate_email" = @Optional({@Assert\Email}),
* "personal_email" = @Assert\Collection\Required({@Assert\NotBlank, @Assert\Email}),
* "alternate_email" = @Assert\Collection\Optional({@Assert\Email}),
* }
* )
*/
Expand All @@ -210,8 +208,6 @@ field is optional but must be a valid email if supplied, you can do the followin
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Constraints\Collection\Optional;
use Symfony\Component\Validator\Constraints\Collection\Required;
class Author
{
Expand All @@ -221,8 +217,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 Required(array(new Assert\NotBlank(), new Assert\Email())),
'alternate_email' => new Optional(array(new Assert\Email())),
'personal_email' => new Assert\Collection\Required(array(new Assert\NotBlank(), new Assert\Email())),
'alternate_email' => new Assert\Collection\Optional(array(new Assert\Email())),
),
)));
}
Expand Down

0 comments on commit 2d4eb95

Please sign in to comment.