Answer the question
In order to leave comments, you need to log in
How to return an object as a result of validation?
For validation, validatejs is used.
When writing my own
validate.validators.myValidator = ......
I can return both a string and an object, but if the validator is written as a function inside constraints,
I can't.
const constraints = {
link: function (value, attributes, attributeName, options, globalOptions) {
return {
error: 'x',
code: 'y'
};
}
};
const links = {
link: 'z'
}
validate(links, constraints)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question