-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Context
- node version: 4.5.0
- joi version: 10.0.6
- environment (node, browser): node
- used with (hapi, standalone, ...): joi-date-extensions
What are you trying to achieve or the steps to reproduce ?
I know that using Joi.any().valid('value') is preferable over using Joi.valid('value'), but the behavior of .describe() is changing between the two cases when Joi is extended.
This change in describe is less than ideal for Felicity since we built off of describe() and hope to support extensions soon.
I'm using joi-date-extensions here, but it appears to be related to .extend rather than the extension itself.
const BaseJoi = require('joi');
const JoiDate = require('joi-date-extensions');
const ExtendedJoi = BaseJoi.extend(JoiDate);
// What I wish users would do, but cannot guarantee:
ExtendedJoi.any().valid('type').default('type').describe();
/*
{ type: 'any',
flags: { allowOnly: true, default: 'type' },
valids: [ 'type' ] }
*/
// How I expect the extended Joi to continue to behave:
BaseJoi.valid('type').default('type').describe();
/*
{ type: 'any',
flags: { allowOnly: true, default: 'type' },
valids: [ 'type' ] }
*/
// Actual extended Joi behavior. Flags and valids are dropped
ExtendedJoi.valid('type').default('type').describe();
/*
{ type: 'any' }
*/Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugBug or defectBug or defect