Skip to content

Commit 400ef54

Browse files
committed
Merge branch '5.0'
* 5.0: Remove AppBundle form path and namespace. refs #13178 [Validator] Added the missing PHP format in a code example
2 parents 4f26e13 + 07c3fdf commit 400ef54

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
@@ -240,3 +240,19 @@ not to the property:
240240
<class name="App\Entity\AcmeEntity">
241241
<constraint name="App\Validator\Constraints\ProtocolClass"/>
242242
</class>
243+
244+
.. code-block:: php
245+
246+
// src/Entity/AcmeEntity.php
247+
use App\Validator\Constraints\ProtocolClass;
248+
use Symfony\Component\Validator\Mapping\ClassMetadata;
249+
250+
class AcmeEntity
251+
{
252+
// ...
253+
254+
public static function loadValidatorMetadata(ClassMetadata $metadata)
255+
{
256+
$metadata->addConstraint(new ProtocolClass());
257+
}
258+
}

0 commit comments

Comments
 (0)