@@ -185,16 +185,14 @@ field is optional but must be a valid email if supplied, you can do the followin
185
185
namespace Acme\BlogBundle\Entity;
186
186
187
187
use Symfony\Component\Validator\Constraints as Assert;
188
- use Symfony\Component\Validator\Constraints\Collection\Optional;
189
- use Symfony\Component\Validator\Constraints\Collection\Required;
190
188
191
189
class Author
192
190
{
193
191
/**
194
192
* @Assert\Collection(
195
193
* fields={
196
- * "personal_email" = @Required({@Assert\NotBlank, @Assert\Email}),
197
- * "alternate_email" = @Optional({@Assert\Email}),
194
+ * "personal_email" = @Assert\Collection\ Required({@Assert\NotBlank, @Assert\Email}),
195
+ * "alternate_email" = @Assert\Collection\ Optional({@Assert\Email}),
198
196
* }
199
197
* )
200
198
*/
@@ -210,8 +208,6 @@ field is optional but must be a valid email if supplied, you can do the followin
210
208
211
209
use Symfony\Component\Validator\Mapping\ClassMetadata;
212
210
use Symfony\Component\Validator\Constraints as Assert;
213
- use Symfony\Component\Validator\Constraints\Collection\Optional;
214
- use Symfony\Component\Validator\Constraints\Collection\Required;
215
211
216
212
class Author
217
213
{
@@ -221,8 +217,8 @@ field is optional but must be a valid email if supplied, you can do the followin
221
217
{
222
218
$metadata->addPropertyConstraint('profileData', new Assert\Collection(array(
223
219
'fields' => array(
224
- 'personal_email' => new Required(array(new Assert\NotBlank(), new Assert\Email())),
225
- 'alternate_email' => new Optional(array(new Assert\Email())),
220
+ 'personal_email' => new Assert\Collection\ Required(array(new Assert\NotBlank(), new Assert\Email())),
221
+ 'alternate_email' => new Assert\Collection\ Optional(array(new Assert\Email())),
226
222
),
227
223
)));
228
224
}
0 commit comments