@@ -251,13 +251,41 @@ each with a single field.
251
251
``ignoreNull ``
252
252
~~~~~~~~~~~~~~
253
253
254
- **type **: ``boolean `` **default **: ``true ``
254
+ **type **: ``boolean ``| `` array `` | `` string `` **default **: ``true ``
255
255
256
256
If this option is set to ``true ``, then the constraint will allow multiple
257
257
entities to have a ``null `` value for a field without failing validation.
258
258
If set to ``false ``, only one ``null `` value is allowed - if a second entity
259
259
also has a ``null `` value, validation would fail.
260
260
261
+ As of Symfony 6.3, the ``UniqueEntity `` constraint allows you to ignore null
262
+ values on specific fields when checking for uniqueness. This feature can be
263
+ helpful when you want to validate the uniqueness of a combination of fields,
264
+ but want to exclude combinations where one or more of the fields are null.
265
+
266
+ ..code-block ::php
267
+
268
+ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
269
+
270
+ #[UniqueEntity(
271
+ fields: ['name', 'email'],
272
+ ignoreNull: 'name',
273
+ )]
274
+
275
+ In the example above, null values for the "name" field will be ignored
276
+ when checking for uniqueness.
277
+
278
+ Similarly, you can ignore null values for multiple fields:
279
+
280
+ ..code-block ::php
281
+
282
+ #[UniqueEntity(
283
+ fields: ['name', 'country', 'email'],
284
+ ignoreNull: ['name', 'country'],
285
+ )]
286
+
287
+ In this case, null values for both the "name" and "country" fields will be ignored.
288
+
261
289
``message ``
262
290
~~~~~~~~~~~
263
291