Skip to content

Commit

Permalink
Add doc for Yaml's option configClass.
Browse files Browse the repository at this point in the history
  • Loading branch information
WedgeSama committed Oct 14, 2024
1 parent 04ccd92 commit e72aca0
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions reference/constraints/Yaml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,69 @@ Parameter Description
``{{ line }}`` The line where the YAML syntax error happened
=============== ==============================================================

``configClass``

Check failure on line 148 in reference/constraints/Yaml.rst

View workflow job for this annotation

GitHub Actions / Lint (DOCtor-RST)

Please ensure title "configClass" and underline length are matching
~~~~~~~~~~~

**type**: ``string`` **default**: ``null``

This option enable a validation check using a class that implement
:class:`Symfony\Component\Config\Definition\ConfigurationInterface`. You need to give it the full classname of your

Check failure on line 154 in reference/constraints/Yaml.rst

View workflow job for this annotation

GitHub Actions / Lint (DOCtor-RST)

Please use 2 backslashes when highlighting a namespace with single backticks: `Symfony\Component\Config\Definition\ConfigurationInterface`
configuration class.

.. configuration-block::

.. code-block:: php-attributes
// src/Entity/Report.php
namespace App\Entity;
use App\Yaml\MyConfiguration;
use Symfony\Component\Validator\Constraints as Assert;
class Report
{
#[Assert\Yaml(
configClass: MyConfiguration::class,
)]
private string $customConfiguration;
}
.. code-block:: php
// src/Entity/Report.php
namespace App\Entity;
use App\Yaml\MyConfiguration;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Mapping\ClassMetadata;
class Report
{
public static function loadValidatorMetadata(ClassMetadata $metadata): void
{
$metadata->addPropertyConstraint('customConfiguration', new Assert\Yaml([
'configClass' => MyConfiguration::class,
]));
}
}
For more info about Configuration, see :doc:`Config component </components/config>`.

``configMessage``

Check failure on line 196 in reference/constraints/Yaml.rst

View workflow job for this annotation

GitHub Actions / Lint (DOCtor-RST)

Please ensure title "configMessage" and underline length are matching
~~~~~~~~~~~

**type**: ``string`` **default**: ``This value do not match the required config.``

This message shown if the given YAML value is invalid regarding the Configuration class.

You can use the following parameters in this message:

=============== ==============================================================
Parameter Description
=============== ==============================================================
``{{ error }}`` The full error message from the config Processor
=============== ==============================================================

.. include:: /reference/constraints/_groups-option.rst.inc

.. include:: /reference/constraints/_payload-option.rst.inc
Expand Down

0 comments on commit e72aca0

Please sign in to comment.