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

string isoDate should allow the string to be converted to same format as date iso schema #1196

Closed
bdgamble opened this issue May 23, 2017 · 0 comments · Fixed by #1197
Closed
Labels
breaking changes Change that can breaking existing code bug Bug or defect feature New functionality or improvement
Milestone

Comments

@bdgamble
Copy link
Contributor

Context

  • node version: all
  • joi version: 10.5.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 ?

Due to a limitation with using joi as the schema for DynamoDb via https://github.com/ryanfitz/vogels I need to validate dates with joi.string().isoDate() and use the value returned from validation to store in DynamoDb. I need the date to be formatted in the simplified extended ISO format in the same way that joi.date().iso() would return.

const stringSchema = Joi.string().isoDate();
const dateSchema = Joi.date().iso();

const stringResults = Joi.validate('2017-01-01', stringSchema);
const dateResults = Joi.validate('2017-01-01', dateSchema);

// want these to be the same
console.log('string value: ', stringResults.result);
console.log('date value: ', dateResults.result);

Which result you had ?

The string schema just returns the provided string. i.e "2017-01-01" returns "2017-01-01"

What did you expect ?

I want it to return "2017-01-01T00:00:00.000Z", or an option to convert it as such

@Marsup Marsup added breaking changes Change that can breaking existing code bug Bug or defect labels Jun 2, 2017
@Marsup Marsup added this to the 11.0.0 milestone Jun 30, 2017
@Marsup Marsup self-assigned this Jun 30, 2017
@hueniverse hueniverse added feature New functionality or improvement and removed request labels Sep 19, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking changes Change that can breaking existing code bug Bug or defect feature New functionality or improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants