Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4e7f2cb

Browse filesBrowse files
committed
Merge branch '4.4' into 5.2
* 4.4: Remove manual enabling of validation and validator annotations
2 parents 8c33c7c + 13f97d7 commit 4e7f2cb
Copy full SHA for 4e7f2cb

File tree

Expand file treeCollapse file tree

2 files changed

+12
-84
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-84
lines changed

‎reference/configuration/framework.rst

Copy file name to clipboardExpand all lines: reference/configuration/framework.rst
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2541,6 +2541,8 @@ enabled
25412541

25422542
**type**: ``boolean`` **default**: ``true`` or ``false`` depending on your installation
25432543

2544+
.. _reference-validation:
2545+
25442546
validation
25452547
~~~~~~~~~~
25462548

‎validation.rst

Copy file name to clipboardExpand all lines: validation.rst
+10-84Lines changed: 10 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ into a database or passed to a web service.
1111
Symfony provides a `Validator`_ component to handle this for you. This
1212
component is based on the `JSR303 Bean Validation specification`_.
1313

14+
.. index::
15+
pair: Validation; Installation
16+
pair: Validation; Configuration
17+
1418
Installation
1519
------------
1620

@@ -21,6 +25,12 @@ install the validator before using it:
2125
2226
$ composer require symfony/validator doctrine/annotations
2327
28+
.. note::
29+
30+
If your application doesn't use Symfony Flex, you might need to do some
31+
manual configuration to enable validation. Check out the
32+
:ref:`Validation configuration reference <reference-validation>`.
33+
2434
.. index::
2535
single: Validation; The basics
2636

@@ -220,90 +230,6 @@ Inside the template, you can output the list of errors exactly as needed:
220230
Each validation error (called a "constraint violation"), is represented by
221231
a :class:`Symfony\\Component\\Validator\\ConstraintViolation` object.
222232

223-
.. index::
224-
pair: Validation; Configuration
225-
226-
Configuration
227-
-------------
228-
229-
Before using the Symfony validator, make sure it's enabled in the main config
230-
file:
231-
232-
.. configuration-block::
233-
234-
.. code-block:: yaml
235-
236-
# config/packages/framework.yaml
237-
framework:
238-
validation: { enabled: true }
239-
240-
.. code-block:: xml
241-
242-
<!-- config/packages/framework.xml -->
243-
<?xml version="1.0" encoding="UTF-8" ?>
244-
<container xmlns="http://symfony.com/schema/dic/services"
245-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
246-
xmlns:framework="http://symfony.com/schema/dic/symfony"
247-
xsi:schemaLocation="http://symfony.com/schema/dic/services
248-
https://symfony.com/schema/dic/services/services-1.0.xsd
249-
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
250-
251-
<framework:config>
252-
<framework:validation enabled="true"/>
253-
</framework:config>
254-
</container>
255-
256-
.. code-block:: php
257-
258-
// config/packages/framework.php
259-
$container->loadFromExtension('framework', [
260-
'validation' => [
261-
'enabled' => true,
262-
],
263-
]);
264-
265-
Besides, if you plan to use annotations to configure validation, replace the
266-
previous configuration by the following:
267-
268-
.. configuration-block::
269-
270-
.. code-block:: yaml
271-
272-
# config/packages/framework.yaml
273-
framework:
274-
validation: { enable_annotations: true }
275-
276-
.. code-block:: xml
277-
278-
<!-- config/packages/framework.xml -->
279-
<?xml version="1.0" encoding="UTF-8" ?>
280-
<container xmlns="http://symfony.com/schema/dic/services"
281-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
282-
xmlns:framework="http://symfony.com/schema/dic/symfony"
283-
xsi:schemaLocation="http://symfony.com/schema/dic/services
284-
https://symfony.com/schema/dic/services/services-1.0.xsd
285-
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
286-
287-
<framework:config>
288-
<framework:validation enable-annotations="true"/>
289-
</framework:config>
290-
</container>
291-
292-
.. code-block:: php
293-
294-
// config/packages/framework.php
295-
$container->loadFromExtension('framework', [
296-
'validation' => [
297-
'enable_annotations' => true,
298-
],
299-
]);
300-
301-
.. tip::
302-
303-
When using PHP, YAML, and XML files instead of annotations, Symfony looks
304-
for by default in the ``config/validator/`` directory, but you can configure
305-
other directories with the :ref:`validation.mapping.paths <reference-validation-mapping>` option.
306-
307233
.. index::
308234
single: Validation; Constraints
309235

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.