Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validating against a schema with array include/exclude may throw an exception #101

Closed
iamdoron opened this issue Jul 4, 2013 · 0 comments · Fixed by #102
Closed

validating against a schema with array include/exclude may throw an exception #101

iamdoron opened this issue Jul 4, 2013 · 0 comments · Fixed by #102
Labels
bug Bug or defect

Comments

@iamdoron
Copy link
Contributor

iamdoron commented Jul 4, 2013

the following test throws:

var schema = {
    arr: Joi.types.Array().includes(Joi.types.Number().integer())
};

var input = { arr: [1, 2, 2.1] };
var err = Joi.validate(input, schema);

expect(err).to.exist;
done();

It happens with almost any variation of types with constraints in include (also for excludes)

another example that throws:

var schema = {
    arr: Joi.types.Array().includes(Joi.types.String())
};

var input = {arr:["1","2","2.1", 2]};
var err = Joi.validate(input, schema);

expect(err).to.exist;
done();

exception for the first case:

TypeError: Cannot call method 'split' of undefined
      at internals.Errors.add (joi/lib/errors.js:20:24)
      at Array.1 (/joi/lib/types/number.js:113:20)
      at Array.1 (/joi/lib/types/array.js:125:47)
      at internals.BaseType.validate (/joi/lib/types/base.js:408:42)
      at validateKeyConfig (/joi/lib/index.js:81:39)
      at processConfig (/joi/lib/index.js:46:13)
      at Object.exports.validate (/joi/lib/index.js:100:5)
      at /joi/test/index.js:501:23
      at Object._onImmediate (/joi/node_modules/lab/lib/execute.js:238:12)
      at processImmediate [as _immediateCallback] (timers.js:330:15)
@ghost ghost assigned geek Jul 5, 2013
@geek geek closed this as completed Jul 5, 2013
@lock lock bot locked as resolved and limited conversation to collaborators Jan 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bug or defect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants