File tree Expand file tree Collapse file tree 2 files changed +53
-3
lines changed Expand file tree Collapse file tree 2 files changed +53
-3
lines changed Original file line number Diff line number Diff line change @@ -2357,7 +2357,51 @@ paths
2357
2357
**type **: ``array `` **default **: ``[] ``
2358
2358
2359
2359
This option allows to define an array of paths with files or directories where
2360
- the component will look for additional validation files.
2360
+ the component will look for additional validation files:
2361
+
2362
+ .. configuration-block ::
2363
+
2364
+ .. code-block :: yaml
2365
+
2366
+ # config/packages/framework.yaml
2367
+ framework :
2368
+ validation :
2369
+ mapping :
2370
+ paths :
2371
+ - " %kernel.project_dir%/validation/"
2372
+
2373
+ .. code-block :: xml
2374
+
2375
+ <!-- config/packages/framework.xml -->
2376
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2377
+ <container xmlns =" http://symfony.com/schema/dic/services"
2378
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
2379
+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
2380
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
2381
+ https://symfony.com/schema/dic/services/services-1.0.xsd
2382
+ http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
2383
+
2384
+ <framework : config >
2385
+ <framework : validation >
2386
+ <framework : mapping >
2387
+ <framework : path >%kernel.project_dir%/validation</framework : path >
2388
+ </framework : mapping >
2389
+ </framework : validation >
2390
+ </framework : config >
2391
+ </container >
2392
+
2393
+ .. code-block :: php
2394
+
2395
+ // config/packages/framework.php
2396
+ $container->loadFromExtension('framework', [
2397
+ 'validation' => [
2398
+ 'mapping' => [
2399
+ 'paths' => [
2400
+ '%kernel.project_dir%/validation',
2401
+ ],
2402
+ ],
2403
+ ],
2404
+ ]);
2361
2405
2362
2406
annotations
2363
2407
~~~~~~~~~~~
Original file line number Diff line number Diff line change @@ -44,8 +44,8 @@ application. The goal of validation is to tell you if the data
44
44
of an object is valid. For this to work, you'll configure a list of rules
45
45
(called :ref: `constraints <validation-constraints >`) that the object must
46
46
follow in order to be valid. These rules are usually defined using PHP code or
47
- annotations but they can also be defined as a `` validation .yaml `` or
48
- ``validation .xml `` file inside the ``config/validator/ `` directory:
47
+ annotations but they can also be defined as `` .yaml `` or
48
+ ``.xml `` files inside the ``config/validator/ `` directory:
49
49
50
50
For example, to guarantee that the ``$name `` property is not empty, add the
51
51
following:
@@ -279,6 +279,12 @@ previous configuration by the following:
279
279
],
280
280
]);
281
281
282
+ .. tip ::
283
+
284
+ When using PHP, YAML, and XML files instead of annotations, Symfony looks
285
+ for by default in the ``config/validator/ `` directory, but you can configure
286
+ other directories with the :ref: `validation.mapping.paths <reference-validation-mapping >` option.
287
+
282
288
.. index ::
283
289
single: Validation; Constraints
284
290
You can’t perform that action at this time.
0 commit comments