Skip to content

some small improvements to the constraints #11411

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
Apr 13, 2019
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
4 changes: 3 additions & 1 deletion reference/constraints/Locale.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ Basic Usage
{
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('locale', new Assert\Locale(['canonicalize' => true]));
$metadata->addPropertyConstraint('locale', new Assert\Locale([
'canonicalize' => true,
]));
}
}

Expand Down
2 changes: 0 additions & 2 deletions reference/constraints/Luhn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ will contain a credit card number.

class Transaction
{
protected $cardNumber;

public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('cardNumber', new Assert\Luhn([
Expand Down
20 changes: 10 additions & 10 deletions reference/constraints/Traverse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ configure the ``Traverse`` constraint on the ``Book`` class.

.. code-block:: php-annotations

// src/AppBundle/Entity/Book.php
namespace AppBundle\Entity;
// src/Entity/Book.php
namespace App\Entity;

use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
Expand All @@ -42,14 +42,14 @@ configure the ``Traverse`` constraint on the ``Book`` class.
/**
* @var Author
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Author")
* @ORM\ManyToOne(targetEntity="App\Entity\Author")
*/
protected $author;

/**
* @var Editor
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Editor")
* @ORM\ManyToOne(targetEntity="App\Entity\Editor")
*/
protected $editor;

Expand All @@ -58,28 +58,28 @@ configure the ``Traverse`` constraint on the ``Book`` class.

.. code-block:: yaml

# src/AppBundle/Resources/config/validation.yml
AppBundle\Entity\Book:
# config/validator/validation.yaml
App\Entity\Book:
constraints:
- Symfony\Component\Validator\Constraints\Traverse: ~

.. code-block:: xml

<!-- src/AppBundle/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"
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping https://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">

<class name="AppBundle\Entity\Book">
<class name="App\Entity\Book">
<constraint name="Symfony\Component\Validator\Constraints\Traverse"/>
</class>
</constraint-mapping>

.. code-block:: php

// src/AppBundle/Entity/Book.php
namespace AppBundle\Entity;
// src/Entity/Book.php
namespace App\Entity;

use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Mapping\ClassMetadata;
Expand Down