validate.js
validate.js copied to clipboard
Typescript Error
I'm getting this error when trying to call the validate function
validate_js_1.default is not a function
I'm importing the lib like this
import validate from 'validate.js'
and calling it this way
validate({}, constraints)
What am I doing wrong?
I'm using typescript 2.5
Thank you!
you need to import like this import * as validate from 'validate.js';.
You might need to cast validate to any before you use it like:
let formValues = (<any>validate).collectFormValues(form);
let validationResult = (<any>validate)(formValues, constraints);
That doesn't seem very nice. I don't use typescript so I'm not really sure how to solve it.