Skip to content

Commit 3f38483

Browse files
committed
Update Collection.rst
Formatting changes per comments from @wouterj
1 parent e83d16f commit 3f38483

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

reference/constraints/Collection.rst

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,7 @@ that if either of the ``personal_email`` or ``short_bio`` elements were missing
164164
from the ``$personalData`` property, no validation error would occur.
165165

166166
.. versionadded:: 2.1
167-
The ``Required`` and ``Optional`` constraint classes were added to give additional
168-
flexibility over the existing ``allowExtraFields`` and ``allowMissingFields`` options
169-
for fields within a Collection.
167+
The ``Required`` and ``Optional`` constraints are new to Symfony 2.1.
170168

171169
Required and Optional Field Constraints
172170
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -195,13 +193,13 @@ field is optional but must be a valid email if supplied, you can do the followin
195193
/**
196194
* @Assert\Collection(
197195
* fields={
198-
* "personal_email" = @Required({@Assert\NotBlank, @Assert\Email}),
196+
* "personal_email" = @Required({@Assert\NotBlank, @Assert\Email}),
199197
* "alternate_email" = @Optional({@Assert\Email}),
200198
* }
201199
* )
202200
*/
203201
protected $profileData = array(
204-
'personal_email'
202+
'personal_email',
205203
);
206204
}
207205
@@ -217,15 +215,15 @@ field is optional but must be a valid email if supplied, you can do the followin
217215
218216
class Author
219217
{
220-
private $options = array();
218+
protected $profileData = array('personal_email');
221219
222220
public static function loadValidatorMetadata(ClassMetadata $metadata)
223221
{
224222
$metadata->addPropertyConstraint('profileData', new Assert\Collection(array(
225223
'fields' => array(
226-
'personal_email' => new Required(array(new Assert\NotBlank(), new Assert\Email())),
224+
'personal_email' => new Required(array(new Assert\NotBlank(), new Assert\Email())),
227225
'alternate_email' => new Optional(array(new Assert\Email())),
228-
)
226+
),
229227
)));
230228
}
231229
}

0 commit comments

Comments
 (0)