Are there any plans to add support for validating the "Unique values" and "Unique values on multiple fields" options from field_validation module?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jelle_S’s picture

These validations require calls to the database. This is a bit too heavy to handle with clientside validation and thus we won't support them. See also #1316678: Field validation not working (comment #3)

Jelle_S’s picture

Status: Active » Closed (won't fix)
attiks’s picture

It would be possible if we can easily plugin to their validation rules, but for the moment all validation is done inside field_validation_field_validation_validate($validator_name, $rule, $entity, $langcode, $items, &$errors), the problem is that we cannot send the full entity to javascript so it can be used as a parameter for a js callback. I think you better open a feature request in field_validation issue queue to ask for a function with minimal (simple) parameters so we can integrate with that.

attiks’s picture

Status: Closed (won't fix) » Postponed
attiks’s picture

Status: Postponed » Needs work

Clientside validation supports ajax based validation rules, the only thing that has to be done is to write the code to integrate it, we don't have the time right now, but patches are always welcome.

barraponto’s picture

Unique values on multiple fields (on the same node) shouldn't require database roundtrips, should it?

barraponto’s picture

Issue summary: View changes
Status: Needs work » Active
Coupon Code Swap’s picture

Perhaps code could be taken from these to implement real-time uniqueness checking:

https://drupal.org/project/formmsgs

https://drupal.org/sandbox/mlncn/1129680

Let me know if this could be sponsored.

barraponto’s picture

Initial support for unique values. Will trigger errors on non-unique values for a single field.

Included:

  • New jQuery.validate selector: :except_value("any value"). Monkeypatched, will be submitted upstream. Required to avoid validating non-unique "_none" options (happens if user leaves some select widgets unattended).
  • Fix _clientside_validation_set_not_equal selector building to include select widgets.
  • Fix to avoid validation for value order (weight) in clientside_validation_field_validation_regular

Lacks:

  • jQuery.validate except_value(): Support for multiple excluded values.
  • Extend :except_value support in _clientside_validation_set_not_equal
  • Interface to decide whether to check empty values as well.
  • Rule group support (multiple field validation).
  • Proper error messages.
  • Minified version of patched jquery.validate (Drupal will minify it when caching, though).
barraponto’s picture

Version: 7.x-1.30 » 7.x-1.x-dev
Status: Active » Needs work
barraponto’s picture

Added rule group support for multiple fields and proper error messages.

jetwodru’s picture

no wonder, been trying hard to figure out why the ajax checking on the uniqueness against existing user's email is not working, wishfully implemented soon, Thanks

barraponto’s picture

@jetwong98 my patch is not dealing with that kind of uniqueness (against other entities'fields) but only on uniqueness among different fields of the same entity.

however, I'd be happy to work on such feature as freelance gig. use my contact form if you're interested.

attiks’s picture

#11 Is this ready for review?

#12 Can you open a separate issue?

barraponto’s picture

@attiks yes, please review it. Bear in mind that it still lacks:

  • jQuery.validate except_value(): Support for multiple excluded values.
  • Extend :except_value support in _clientside_validation_set_not_equal
  • Interface to decide whether to check empty values as well.
  • Minified version of patched jquery.validate (Drupal will minify it when caching, though).

And, yes, I patched jquery.validate.js. I know I should open a bug upstream, or maybe add an auxiliary jquery file.

FireHawkX’s picture

#11 no longer apply to latest version...