async-validator
async-validator copied to clipboard
The syntax error is caught but this error should be thrown to the developer
Version
3.0.5
Steps to reproduce code
import Schema from "async-validator";
const rule = {
validator: () => {
// here is syntax error
// aaa not define
// should throw error
console.log(aaa);
},
trigger: 'change'
}
const descriptor = {
name: rule
}
const validator = new Schema(descriptor)
validator.validate({ name: 'pomelo' }, (errors, fields) => {
if (errors) {
// validation failed, errors is an array of all errors
// fields is an object keyed by field name with an array of
// errors per field
return handleErrors(errors, fields);
}
// validation passed
});
What is expected?
The developer should get error
What is actually happening?
The developer does not know what happened
Error Description
If there is a syntax error in the validator function of the rule, this error should be thrown to the developer
https://github.com/yiminghe/async-validator/blob/master/src/util.js#L203