Parsley.js icon indicating copy to clipboard operation
Parsley.js copied to clipboard

Pass field element reference into validation callback

Open velosipedist opened this issue 10 years ago • 3 comments

I have custom validators which not just check some hardcoded data conditions, but depends on validated input and/or it's neighbours state.

It requires at least reference to the input itself.

At first glance, it can be solved just adding input reference here (passing it through then into validateThroughValidator()).

velosipedist avatar May 27 '14 10:05 velosipedist

I've resolved it using this code:

validateThroughValidator: function (value, constraints, priority) {
      var that = this;
      $.each(constraints, function() { this.$element = that.$element });
      return window.ParsleyValidator.validate.apply(window.ParsleyValidator, [value, constraints, priority]);
    },

efreibe avatar Dec 16 '14 15:12 efreibe

Related to #839

marcandre avatar Feb 10 '15 20:02 marcandre

This would be very useful :+1:

chibicode avatar Mar 23 '15 19:03 chibicode