-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Milestone
Description
Below is a test case that produces the issue. In other words, it only supports homogeneous arrays - not heterogeneous arrays. However, according to the docs, it should be able to support heterogeneous arrays.
describe.only('Joi Array Type', function() {
it('can validate that its elements only include certain types', function() {
var schema = {
array : joi.types.Array().includes(joi.types.String().min(5), joi.types.Number().min(0))
};
var obj = {
array : [ '12345' ]
};
var err = joi.validate(obj, schema);
if (err) {
throw new Error(JSON.stringify(obj) + '\n' + err);
}
obj = {
array : [ '1234' ]
};
err = joi.validate(obj, schema);
if (!err) {
throw new Error(JSON.stringify(obj) + '\n Should be invalid because it contains a String with length < 5');
}
obj = {
array : [ 3 ]
};
err = joi.validate(obj, schema);
if (err) {
throw new Error(JSON.stringify(obj) + '\n' + err);
}
obj = {
array : [ '12345', 3 ]
};
err = joi.validate(obj, schema);
if (err) {
throw new Error(JSON.stringify(obj) + '\n' + err);
}
});
});Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels