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