Skip to content
Closed
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
14 changes: 14 additions & 0 deletions book/validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,20 @@ object, which acts just like an array of errors. Each error in the collection
is a :class:`Symfony\\Component\\Validator\\ConstraintViolation` object,
which holds the error message on its ``getMessage`` method.

Using the Validator outside the Symfony framework context
---------------------------------------------------------

The Symfony ``validator`` can be used outside Symfony framework thanks to the :class: `Symfony\Component\Validator\ValidatorBuilder`:

use Symfony\Component\Validator\ValidatorBuilder;

$validator = (new ValidatorBuilder())
->addMethodMapping('loadValidatorMetadata')
->getValidator();

The ValidatorBuilder accept also Yaml or Xml mappings, you only need to set up the ``addXmlMapping/addYamlMapping`` methods with the correct path to the file. To enable the annotations, the method ``enableAnnotationMapping`` is available.


Final Thoughts
--------------

Expand Down