Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 767e19e

Browse filesBrowse files
committed
Merge branch '4.2'
* 4.2: [Validator] Improve raw value validation Fix classes generation with YAML or XML metadata.
2 parents f0e32cd + b5e0a70 commit 767e19e
Copy full SHA for 767e19e

File tree

2 files changed

+54
-1
lines changed
Filter options

2 files changed

+54
-1
lines changed

‎doctrine/reverse_engineering.rst

Copy file name to clipboardExpand all lines: doctrine/reverse_engineering.rst
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,23 @@ files: ``BlogPost.php`` and ``BlogComment.php``.
7070
7171
$ php bin/console doctrine:mapping:import 'App\Entity' xml --path=config/doctrine
7272
73+
In this case, make sure to adapt your mapping configuration accordingly:
74+
75+
.. code-block:: yaml
76+
77+
# config/packages/doctrine.yaml
78+
doctrine:
79+
# ...
80+
orm:
81+
# ...
82+
mappings:
83+
App:
84+
is_bundle: false
85+
type: yml # Set to xml in case of XML mapping
86+
dir: '%kernel.project_dir%/config/doctrine'
87+
prefix: 'App\Entity'
88+
alias: App
89+
7390
Generating the Getters & Setters or PHP Classes
7491
-----------------------------------------------
7592

‎validation/raw_values.rst

Copy file name to clipboardExpand all lines: validation/raw_values.rst
+37-1Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,26 @@ Validation of arrays is possible using the ``Collection`` constraint::
5151

5252
$validator = Validation::createValidator();
5353

54+
$input = array(
55+
'name' => array(
56+
'first_name' => 'Fabien',
57+
'last_name' => 'Potencier',
58+
),
59+
'email' => 'test@email.tld',
60+
'simple' => 'hello',
61+
'gender' => 3,
62+
'file' => null,
63+
'password' => 'test',
64+
'tags' => array(
65+
array(
66+
'slug' => 'symfony_doc',
67+
'label' => 'symfony doc',
68+
),
69+
),
70+
);
71+
72+
$groups = new Assert\GroupSequence(array('Default', 'custom'));
73+
5474
$constraint = new Assert\Collection(array(
5575
// the keys correspond to the keys in the input array
5676
'name' => new Assert\Collection(array(
@@ -62,9 +82,25 @@ Validation of arrays is possible using the ``Collection`` constraint::
6282
'gender' => new Assert\Choice(array(3, 4)),
6383
'file' => new Assert\File(),
6484
'password' => new Assert\Length(array('min' => 60)),
85+
'tags' => new Assert\Optional(array(
86+
new Assert\Type('array'),
87+
new Assert\Count(array('min' => 1)),
88+
new Assert\All(array(
89+
new Assert\Collection(array(
90+
'slug' => array(
91+
new Assert\NotBlank(),
92+
new Assert\Type(array('type' => 'string'))
93+
),
94+
'label' => array(
95+
new Assert\NotBlank(),
96+
),
97+
)),
98+
new CustomUniqueTagValidator(array('groups' => 'custom')),
99+
)),
100+
)),
65101
));
66102

67-
$violations = $validator->validate($input, $constraint);
103+
$violations = $validator->validate($input, $constraint, $groups);
68104

69105
The ``validate()`` method returns a :class:`Symfony\\Component\\Validator\\ConstraintViolationList`
70106
object, which acts just like an array of errors. Each error in the collection

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.