Skip to content

Issue with ".allow" whitelists #13

@david-unergie

Description

@david-unergie

Context

  • node version: v6.9.2
  • joi version: v10.6.0 / v11.4.0 / v12.0.0 / v13.7.0 / v14.3.0
  • environment (node, browser): node
  • used with (hapi, standalone, ...): standalone
  • any other relevant information: joi-date-extensions v1.2.0

What are you trying to achieve or the steps to reproduce ?

The whitelisting behavior ".allow" seems not working since Joi.date().format() is in an external module.

Working with joi v9.2.0:

const joi = require('joi')
joi.date().format('YYYY-MM-DD').allow('epoch', 'start', 'end').validate('epoch')

Failing with v10.6.0 / v11.4.0 / v12.0.0 / v13.7.0 / v14.3.0:

const joi = require('joi').extend(require('joi-date-extensions'))
joi.date().format('YYYY-MM-DD').allow('epoch', 'start', 'end').validate('epoch')
// => "value" must be a string with one of the following formats [YYYY-MM-DD]

Which result you had ?

"value" must be a string with one of the following formats [YYYY-MM-DD]

What did you expect ?

No error

Metadata

Metadata

Assignees

Labels

bugBug or defect

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions