ansman/validate.js

validate.single datetime without calling validate.extend?

Opened this issue · 0 comments

I'm using validate.js inside a React component, and using validate.single internally using constraints passed into the component. It works great, however I can't get datetime to work as I don't expose the validate object to users.

Looking at:
https://github.com/ansman/validate.js/blob/master/validate.js#L193

I thought I could pass the parse and format functions as option:

const message = validate.single('', {
    presence: true,
    datetime: true
  }, {
    parse: value => fecha.parse(value, 'M/D/YYYY'),
    format: value => fecha.format(value, 'M/D/YYYY')
  });

But does not seem to work, same error: [Error] Error: Both the parse and format functions needs to be set to use the datetime/date validator