Hi.

The validator "unique value on multiple fields" points empty values as non unique.
When this will happen? If you have two empty fields or two empty instances - delta 0 and 1 - of a multiple valued field the validator will trigger and will not allow you to continue.

I believe this is a bad behavior since drupal will always ignore empty values and will not save it to the database.
I also believe you might use mandatory fields if you need to avoid them to be empty.

The available patch changes this behavior and the validator "unique value on multiple fields" will ignore all empty values when checking the uniqueness.

A numeric with zero or a text with spaces are not empty!

Regards,
Gilsberty

CommentFileSizeAuthor
#1 field_validation-2241699-1.patch1.04 KBgilsbert
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gilsbert’s picture

Patch for the issue!

rakesh.nimje84@gmail.com’s picture

Status: Reviewed & tested by the community » Needs review

On which version I should apply this patch because there is difference in the file which you have mentioned.

gilsbert’s picture

Hi @rakesh.nimje84 .

For the version 7.x-2.4 of field_validation the issue is gone and my patch is not necessary anymore. After reading your message I did the test using a multivalued text field and a multivalued entity reference field with success.

In another words: the maintainer fixed the issue and the validator "unique value on multiple fields" no longer points empty values as non unique.

I recommend the version 7.x-2.4 and I'm marking this issue as closed (fixed).

I would like to thank the module's maintainer for the changes on the validator.

Regards,
Gilsberty

gilsbert’s picture

Status: Needs review » Closed (fixed)
scotwith1t’s picture

Perhaps this is fixed for the multiple values option, but it still fails validation if you use the Unique Values option (not multiple) and considers the empty field not unique. Perhaps there's a way to do this with conditional validation or some setting on the rule, but I can't figure a way to make it work...creating new issue since I can't reopen...