mustardamus/ketchup-plugin — Issue #57: Custom validations fail if they take a parameter and end in "on"
Author: sblackstone
Created: 2012-01-11 18:24:07+00:00
State: open

Custom validations will fail if they take a parameter and end in "on"

Suppose you create a function -

*password_confirmation(.orig_password_field)*

This would become:

*data-validate="validate(password_confirmation(.orig_password_field))"*

Look at the function "extractEvents" -

extractEvents: function(toExtract, indicator) {
var events = false,
pos = toExtract.indexOf(indicator + '(');

In the default release indicator is "on". Ergo, for the example above, it ends up returning the parameter we're passing into our custom validation. Instead, extract events should return false so that the default events are used.

The fix would be to change the code so that it does a regex for a space or a quote mark followed by the indicator... This allows the indicator to start the validation string or be placed after it provided there is a space..

The temporary workaround we're using is changing the indicator to " on" and requring that the on part of the statement always be specified second.