Skip to content

Better explain how to enable the validation component and its annotations #7836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
39 changes: 37 additions & 2 deletions validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,43 @@ Configuration
-------------

Before using the Symfony validator, make sure it's enabled in the main config
file. Besides, if you plan to use annotations to configure validation, make sure
that the ``enable_annotations`` option is ``true``:
file:

.. configuration-block::

.. code-block:: yaml

# app/config/config.yml
framework:
validation: { enabled: true }

.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">

<framework:config>
<framework:validation enabled="true" />
</framework:config>
</container>

.. code-block:: php

// app/config/config.php
$container->loadFromExtension('framework', array(
'validation' => array(
'enabled' => true,
),
));

Besides, if you plan to use annotations to configure validation (as recommended
by the official Symfony Best Practices), replace the previous configuration by
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add some link?

Copy link
Member Author

@javiereguiluz javiereguiluz Apr 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed this because I cannot find any reference to this in the Best Practices. So it's not a best practice but just my imagination inventing things 😁

the following:

.. configuration-block::

Expand Down