Skip to content

Commit bd56621

Browse files
committed
Merge branch '3.4' into 4.4
* 3.4: [Validator] Added the missing PHP format in a code example
2 parents d1fe7ab + a41bac9 commit bd56621

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

validation/custom_constraint.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,19 @@ not to the property:
245245
<class name="App\Entity\AcmeEntity">
246246
<constraint name="App\Validator\Constraints\ProtocolClass"/>
247247
</class>
248+
249+
.. code-block:: php
250+
251+
// src/AppBundle/Entity/AcmeEntity.php
252+
use AppBundle\Validator\Constraints\ProtocolClass;
253+
use Symfony\Component\Validator\Mapping\ClassMetadata;
254+
255+
class AcmeEntity
256+
{
257+
// ...
258+
259+
public static function loadValidatorMetadata(ClassMetadata $metadata)
260+
{
261+
$metadata->addConstraint(new ProtocolClass());
262+
}
263+
}

0 commit comments

Comments
 (0)