Datetime Validator option functions not being called
thomasrstorey opened this issue · 0 comments
In the documentation, it states
"validate.js allows the validators object and validator options to be a function that should return the constraints/options".
I am trying to make a Date Range field that will correctly validate ranges where the start is after the end, or the end is before the start, as invalid. I have implemented an earliest
option on a date
constraint for my date_end
field as follows:
date: {
earliest: function(val, attr, opts, attrs){
return moment.utc(attrs.date_start);
}
}
Additionally I have defined a parse
function on the validator as follows:
parse: function(value, options) {
return +moment.utc(value);
},
However on inspection, I find that the value getting passed to my parse
function is not the return value of the above function, but the function object itself, which is evaluated by +moment.utc
as NaN
Shouldn't my parse be getting the return value of my earliest
function instead of the function itself? This seems to be what is described in the documentation.
Thanks for a great library otherwise!