@@ -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,53 @@ previous configuration by the following:
279
279
],
280
280
]);
281
281
282
+ By default, config files are located in the ``config/validator/ `` directory.
283
+ It is possible to define an array of paths with files or directories where the component will look for additional validation files:
284
+
285
+ .. configuration-block ::
286
+
287
+ .. code-block :: yaml
288
+
289
+ # config/packages/framework.yaml
290
+ framework :
291
+ validation :
292
+ mapping :
293
+ paths :
294
+ - " %kernel.project_dir%/validation/"
295
+
296
+ .. code-block :: xml
297
+
298
+ <!-- config/packages/framework.xml -->
299
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
300
+ <container xmlns =" http://symfony.com/schema/dic/services"
301
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
302
+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
303
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
304
+ https://symfony.com/schema/dic/services/services-1.0.xsd
305
+ http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
306
+
307
+ <framework : config >
308
+ <framework : validation >
309
+ <framework : mapping >
310
+ <framework : path >%kernel.project_dir%/validation</framework : path >
311
+ </framework : mapping >
312
+ </framework : validation >
313
+ </framework : config >
314
+ </container >
315
+
316
+ .. code-block :: php
317
+
318
+ // config/packages/framework.php
319
+ $container->loadFromExtension('framework', [
320
+ 'validation' => [
321
+ 'mapping' => [
322
+ 'paths' => [
323
+ '%kernel.project_dir%/validation',
324
+ ],
325
+ ],
326
+ ],
327
+ ]);
328
+
282
329
.. index ::
283
330
single: Validation; Constraints
284
331
0 commit comments