-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Context
- node version: 10.14.0
- joi version: 16.0.0-preview
- environment (node, browser): node
- used with (hapi, standalone, ...): standalone
- any other relevant information:
What are you trying to achieve or the steps to reproduce ?
const Joi = require('@hapi/joi');
const schema = Joi.object({
FundingSources: Joi.array().optional()
.items(
Joi.string().valid('All', 'Balance')
)
.length(1)
.default(['All'])
});
console.log(schema.describe());Which result you had ?
node_modules/@hapi/joi/lib/index.js:214
throw error;
^
ValidationError: {
"type": "array",
"flags": {
"presence": "optional",
"default" [1]: [
"All"
]
},
"rules": [
{
"name": "length",
"args": {
"limit": 1
}
}
],
"items": [
{
"type": "string",
"flags": {
"only": true
},
"allow": [
"All",
"Balance"
]
}
]
}
[1] "flags.default" must be one of [boolean, object, number, string, object, object, object, object, object, object, object, object]What did you expect ?
Proper output of schema.describe().
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugBug or defectBug or defect