-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Support plan
- is this issue currently blocking your project? (yes/no): yes
- is this issue affecting a production system? (yes/no): no
Context
- node version: v14.6.0
- module version with issue:
- last module version without issue:
- environment (e.g. node, browser, native): node
- used with (e.g. hapi application, another framework, standalone, ...): standalone
- any other relevant information:
What are you trying to achieve or the steps to reproduce?
It looks like stripUnknown doesn't works for nested object when the nested object has invalid fields.
const schema = Joi.object({
foo: Joi.string(),
nested: Joi.object({
bar: Joi.string(),
})
})
const options = {
abortEarly: false,
allowUnknown: true,
presence: 'required',
stripUnknown: true,
}
const input = {
foo: null, // invalid value
unknown: 'unknown',
nested: {
bar: null, // invalid value
unknown: 'unknown',
}
}
const { value } = schema.validate(input, options)
// { foo: null, nested: { bar: null, unknown: 'unknown' } }What was the result you got?
nested.unknow is still present
What result did you expect?
It should have been "stripped"
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugBug or defectBug or defect