tmpfs / async-validate

Asynchronous type validation for node and the browser
Other
314 stars 45 forks source link

after invoke some times, the `type: ['string', 'object']` --> `type: ['string']. #64

Open jeff0905 opened 5 years ago

jeff0905 commented 5 years ago

after invoke some times. the type: ['string', 'object'] --> `type: ['string'].

jeff0905 commented 5 years ago
  type: ['string', 'object'],
  test: function(cb) {
    const thisField = this.value;
    // check....
    cb();
  }
jeff0905 commented 5 years ago

type.js:90 Uncaught TypeError: list.map is not a function at Fn.types [as test] (type.js:90) at schema.js:331 at run (iterator.js:5) at mapSeries (iterator.js:18) at Schema.validate (schema.js:197) at iterator (schema.js:314) at run (iterator.js:5) at mapSeries (iterator.js:18) at onValidate (schema.js:251) at Fn.test (event.js:53) at schema.js:331 at run (iterator.js:5) at mapSeries (iterator.js:18) at Schema.validate (schema.js:197)

jeff0905 commented 5 years ago

if i should code like this email: [ {type: "string", required: true}, function(cb) { // test if email address (this.value) already exists // in a database and call this.raise() if it does cb(); } ] because this code before: type: ['string', 'object'], test: function(cb) { const thisField = this.value; // check.... cb(); }

jeff0905 commented 5 years ago

after check my code, i found that if we invoke some times , the type: ['string', Number] throw errors,

but, type: ['string', 'number] can't throw error after invoking some times.

tmpfs commented 5 years ago

Thanks for the bug report @jeff0905, can you provide a copy and paste example that reproduces the issue please. If I can reproduce it, I should be able to fix it quickly. Thanks.