async-validator icon indicating copy to clipboard operation
async-validator copied to clipboard

The syntax error is caught but this error should be thrown to the developer

Open pomeloneo opened this issue 4 years ago • 0 comments

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

pomeloneo avatar Jan 06 '21 04:01 pomeloneo