Skip to content

Commit 443ee4d

Browse files
Add identifierFieldNames option details to Update UniqueEntity.rst
This option was missing from the docs for this constraint, so adding based on my inturpretation of the code.
1 parent 291147e commit 443ee4d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

reference/constraints/UniqueEntity.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,28 @@ If you need to require two fields to be individually unique (e.g. a unique
272272
``email`` and a unique ``username``), you use two ``UniqueEntity`` entries,
273273
each with a single field.
274274

275+
``identifierFieldNames``
276+
~~~~~~~~~~
277+
278+
**type**: ``array``
279+
280+
When applying the constraint to a non-entity class, this allows you to specify
281+
which field(s), on the object being validated, should be used to determine
282+
whether the object being validated is the same as an existing entity found
283+
with matching field value(s).
284+
285+
If the value(s) found in the object being validated's ``identifierFieldNames``
286+
fields match the itentifiers of the object found in the databased, then that
287+
match is permitted. If the identifiers to not match, then the found record
288+
will cause the valudation to fail.
289+
290+
.. warning::
291+
292+
The array of values given should be the same as the identifier fields on
293+
the entity class, otherwise a
294+
``\Symfony\Component\Validator\Exception\ConstraintDefinitionException``
295+
will be thrown during validation.
296+
275297
.. include:: /reference/constraints/_groups-option.rst.inc
276298

277299
``ignoreNull``

0 commit comments

Comments
 (0)