-
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: 12.x
- module version with issue: 17.3.0
- last module version without issue: n/a
- environment (e.g. node, browser, native): node
- used with (e.g. hapi application, another framework, standalone, ...): standalone
What are you trying to achieve or the steps to reproduce?
Properties with defaults should be applied, even if they're part of an alternative subschema with a match mode.
const joi = require('joi')
const s = joi.alternatives().try(
joi.object({
lol: joi.string().default('rofl')
}).unknown(),
joi.object({
foo: joi.string().default('bar'),
baz: joi.string()
})
).match('all')
const { value, error } = s.validate({ baz: 'bing' })What was the result you got?
error === undefined
value === { baz: 'bing' }What result did you expect?
error === undefined
value === { lol: 'rofl', foo: 'bar', baz: 'bing' }Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugBug or defectBug or defect