Skip to content

Commit a2765d3

Browse files
authored
[WIP][DoctrineBridge] Allow validating every class against unique entity constraint
Need to add so info about: - the mapping between the DTOs fields and the targeted entity fields (identifierFieldNames and fields option) - some example, probably in identifierFieldNames - another use case of entityClass in the context of DTO
1 parent 5f82d44 commit a2765d3

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

reference/constraints/UniqueEntity.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ using an email address that already exists in the system.
99

1010
If you want to validate that all the elements of the collection are unique
1111
use the :doc:`Unique constraint </reference/constraints/Unique>`.
12+
13+
.. versionadded:: 5.2
14+
15+
Not entity (like DTO) field (or fields) validation against entities persisted in the database, was introduced in Symfony 5.2.
1216

1317
========== ===================================================================
1418
Applies to :ref:`class <validation-class-target>`
@@ -17,6 +21,7 @@ Options - `em`_
1721
- `errorPath`_
1822
- `fields`_
1923
- `groups`_
24+
- `identifierFieldNames`_
2025
- `ignoreNull`_
2126
- `message`_
2227
- `payload`_
@@ -261,6 +266,21 @@ each with a single field.
261266

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

269+
270+
identifierFieldNames
271+
~~~~~~~~~~
272+
273+
**type**: ``array`` | ``string`` [:ref:`default option <validation-default-option>`]
274+
275+
This optional option is the field (or list of fields) of identifier field names
276+
that are defined in the entity set by the `entityClass`_ option.
277+
278+
Use it only when the checked object is not an entity and you need to update an entity.
279+
280+
.. versionadded:: 5.2
281+
282+
The option was introduced in Symfony 5.2.
283+
264284
ignoreNull
265285
~~~~~~~~~~
266286

0 commit comments

Comments
 (0)