-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
(I imagine very few people running into an issue like this, so I would say this is very very low priority. Still, worth fixing (I'm picking it up when I have the time if anyone else doesn't))
This happens:
> var schema = Joi.object({ a: Joi.any().valid(undefined).required() })
{ isJoi: true,
_type: 'object',
_settings: null,
_valids: { _set: [] },
_invalids: { _set: [] },
_tests: [],
_refs: [],
_flags: {},
_description: null,
_unit: null,
_notes: [],
_tags: [],
_examples: [],
_meta: [],
_inner:
{ children: [ [Object] ],
renames: [],
dependencies: [],
patterns: [] } }
> Joi.validate({a: 1}, schema)
{ error:
{ [ValidationError: child "a" fails because ["a" must be one of []]]
name: 'ValidationError',
details: [ [Object] ],
_object: { a: 1 },
annotate: [Function] },
value: { a: 1 } }
> Joi.validate({a: undefined}, s)
{ error:
{ [ValidationError: child "a" fails because ["a" is required]]
name: 'ValidationError',
details: [ [Object] ],
_object: { a: undefined },
annotate: [Function] },
value: { a: undefined } }
> Joi.validate({}, s)
{ error:
{ [ValidationError: child "a" fails because ["a" is required]]
name: 'ValidationError',
details: [ [Object] ],
_object: {},
annotate: [Function] },
value: {} }Perhaps Joi should not allow .valid(undefined).required().
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugBug or defectBug or defect