Skip to content

Add new validator config & translations path #8633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ following:

.. code-block:: yaml

# src/Resources/config/validation.yml
# config/validator/validation.yaml
App\Entity\Author:
properties:
name:
- NotBlank: ~

.. code-block:: xml

<!-- src/Resources/config/validation.xml -->
<!-- config/validator/validation.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand Down Expand Up @@ -214,13 +214,13 @@ file:

.. code-block:: yaml

# app/config/config.yml
# config/packages/framework.yaml
framework:
validation: { enabled: true }

.. code-block:: xml

<!-- app/config/config.xml -->
<!-- config/packages/framework.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand All @@ -236,7 +236,7 @@ file:

.. code-block:: php

// app/config/config.php
// config/packages/framework.php
$container->loadFromExtension('framework', array(
'validation' => array(
'enabled' => true,
Expand All @@ -250,13 +250,13 @@ previous configuration by the following:

.. code-block:: yaml

# app/config/config.yml
# config/packages/framework.yml
framework:
validation: { enable_annotations: true }

.. code-block:: xml

<!-- app/config/config.xml -->
<!-- config/packages/framework.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand All @@ -272,7 +272,7 @@ previous configuration by the following:

.. code-block:: php

// app/config/config.php
// config/packages/framework.php
$container->loadFromExtension('framework', array(
'validation' => array(
'enable_annotations' => true,
Expand Down Expand Up @@ -346,7 +346,7 @@ literature genre mostly associated with the author, which can be set to either

.. code-block:: yaml

# src/Resources/config/validation.yml
# config/validator/validation.yaml
App\Entity\Author:
properties:
genre:
Expand All @@ -355,7 +355,7 @@ literature genre mostly associated with the author, which can be set to either

.. code-block:: xml

<!-- src/Resources/config/validation.xml -->
<!-- config/validator/validation.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand Down Expand Up @@ -430,7 +430,7 @@ options can be specified in this way.

.. code-block:: yaml

# src/Resources/config/validation.yml
# config/validator/validation.yml
App\Entity\Author:
properties:
genre:
Expand All @@ -439,7 +439,7 @@ options can be specified in this way.

.. code-block:: xml

<!-- src/Resources/config/validation.xml -->
<!-- config/validator/validation.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand Down Expand Up @@ -559,7 +559,7 @@ class to have at least 3 characters.

.. code-block:: yaml

# src/Resources/config/validation.yml
# config/validator/validation.yaml
App\Entity\Author:
properties:
firstName:
Expand All @@ -569,7 +569,7 @@ class to have at least 3 characters.

.. code-block:: xml

<!-- src/Resources/config/validation.xml -->
<!-- config/validator/validation.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand Down Expand Up @@ -647,15 +647,15 @@ this method must return ``true``:

.. code-block:: yaml

# src/Resources/config/validation.yml
# config/validator/validation.yaml
App\Entity\Author:
getters:
passwordLegal:
- 'IsTrue': { message: 'The password cannot match your first name' }

.. code-block:: xml

<!-- src/Resources/config/validation.xml -->
<!-- config/validator/validation.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand Down
12 changes: 6 additions & 6 deletions validation/translations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ property is not empty, add the following:

.. code-block:: yaml

# src/Resources/config/validation.yml
# config/validator/validation.yaml
App\Entity\Author:
properties:
name:
- NotBlank: { message: 'author.name.not_blank' }

.. code-block:: xml

<!-- src/Resources/config/validation.xml -->
<!-- config/validator/validation.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand Down Expand Up @@ -84,13 +84,13 @@ property is not empty, add the following:
}
}

Now, create a ``validators`` catalog file in the ``app/Resources/translations`` directory:
Now, create a ``validators`` catalog file in the ``config/translations/`` directory:

.. configuration-block::

.. code-block:: xml

<!-- app/Resources/translations/validators.en.xlf -->
<!-- config/translations/validators.en.xlf -->
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
Expand All @@ -105,12 +105,12 @@ Now, create a ``validators`` catalog file in the ``app/Resources/translations``

.. code-block:: yaml

# app/Resources/translations/validators.en.yml
# config/translations/validators.en.yaml
author.name.not_blank: Please enter an author name.

.. code-block:: php

// app/Resources/translations/validators.en.php
// config/translations/validators.en.php
return array(
'author.name.not_blank' => 'Please enter an author name.',
);
Expand Down