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
23572357**type **: ``array `` **default **: ``[] ``
23582358
23592359This 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+ ]);
23612405
23622406 annotations
23632407~~~~~~~~~~~
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
4444of an object is valid. For this to work, you'll configure a list of rules
4545(called :ref: `constraints <validation-constraints >`) that the object must
4646follow 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:
4949
5050For example, to guarantee that the ``$name `` property is not empty, add the
5151following:
@@ -279,6 +279,12 @@ previous configuration by the following:
279279 ],
280280 ]);
281281
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+
282288.. index ::
283289 single: Validation; Constraints
284290
You can’t perform that action at this time.
0 commit comments