Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with optional date #2

Closed
bnadim opened this issue Nov 22, 2016 · 2 comments
Closed

Issue with optional date #2

bnadim opened this issue Nov 22, 2016 · 2 comments
Assignees
Labels
bug Bug or defect
Milestone

Comments

@bnadim
Copy link

bnadim commented Nov 22, 2016

Context

  • node version: 6.9.1
  • joi version: 10.0.1 - extension 1.0.0
  • environment (node, browser): node
  • used with (hapi, standalone, ...): standalone
  • any other relevant information:

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

Fields with format option become required even if they are written as optional

const BaseJoi = require('joi')
const Extension = require('joi-date-extensions')
const Joi = BaseJoi.extend(Extension)

const schema = Joi.object().required().keys({
    date: Joi.date().format('YYYY-MM-DD').optional()
});

const data = { }

Joi.validate(data, schema, { allowUnknown: true }, (err, validatedData) => {
    if (err) {
        console.log('Validation error : ', err)
    } else {
        console.log('Validation success')
    }
})

Which result you had ?

'"date" must be a string with one of the following formats YYYY-MM-DD'

What did you expect ?

Data should be a valid result

@Marsup Marsup added the bug Bug or defect label Nov 22, 2016
@Marsup Marsup self-assigned this Nov 22, 2016
@Marsup Marsup added this to the 1.0.1 milestone Nov 22, 2016
@Marsup Marsup closed this as completed in df08465 Nov 22, 2016
@Marsup
Copy link
Collaborator

Marsup commented Nov 22, 2016

Thanks for the report, patch published.

@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bug or defect
Projects
None yet
Development

No branches or pull requests

2 participants