Closed dim882 closed 10 years ago
Hmm, this
should refer to the datetime
validator when called since validate.js calls each validator like this:
results.push({
attribute: attr,
error: validator.call(validator, value, validatorOptions, attr,
attributes)
});
Could you add a console.log(this)
before line 622 and see what this
refers to?
Ah, I see. Thanks for getting the fix out so quickly!
I'm attempting to use moment.js for date validations, and I have a validation rule that's pretty much the same as the XDate example in the documentation:
but I get an "Uncaught TypeError: undefined is not a function validate.js:622". It appears it's attempting to call
#parse
wherethis
is thevalidators
object, not thedatetime
object, so it fails. I wonder if it's possible I'm callingvalidate()
wrong and screwing up the context, but I can't find anything in my code that would cause that.Anyway, I'll submit a pull request soon with a fix that works for me, but let me know if this is incorrect.