Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions reference/constraints/Collection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,22 @@ field is optional but must be a valid email if supplied, you can do the followin

.. configuration-block::

.. code-block:: yaml

# src/Acme/BlogBundle/Resources/config/validation.yml
Acme\BlogBundle\Entity\Author:
properties:
profile_data:
- Collection:
fields:
personal_email:
- Collection\Required
- NotBlank: ~
- Email: ~
alternate_email:
- Collection\Optional:
- Email: ~

.. code-block:: php-annotations

// src/Acme/BlogBundle/Entity/Author.php
Expand All @@ -200,6 +216,35 @@ field is optional but must be a valid email if supplied, you can do the followin
'personal_email',
);
}

.. code-block:: xml

<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">

<class name="Acme\BlogBundle\Entity\Author">
<property name="profile_data">
<constraint name="Collection">
<option name="fields">
<value key="personal_email">
<constraint name="Collection\Required">
<constraint name="NotBlank" />
<constraint name="Email" />
</constraint>
</value>
<value key="alternate_email">
<constraint name="Collection\Optional">
<constraint name="Email" />
</constraint>
</value>
</option>
</constraint>
</property>
</class>
</constraint-mapping>

.. code-block:: php

Expand Down