-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
breaking changesChange that can breaking existing codeChange that can breaking existing codefeatureNew functionality or improvementNew functionality or improvement
Milestone
Description
Describe the problem you are trying to fix (provide as much context as possible)
Error messages for min, max, greater and less of the date type use the default date string formatting which results in unreadable error messages, e.g.:
const Joi = require('joi');
Joi.assert(
new Date('2000-01-01T00:00:00.000Z'),
Joi.date().less(new Date('2000-01-01T00:00:00.000Z')
));[1] "value" must be less than "Sat Jan 01 2000 02:00:00 GMT+0200 (Jerusalem Standard Time)"
They also use the local timezone making it harder to unit tests for the expected message string.
Using ISO formatting would result a) more readable error message b) always in UTC:
[1] "value" must be less than "2000-01-01T00:00:00.000Z"
Which API (or modification of the current API) do you suggest to solve that problem ?
Convert the limit parameter to string using .toISOString() before passing it to createError
Are you ready to work on a pull request if your suggestion is accepted ?
Yes.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
breaking changesChange that can breaking existing codeChange that can breaking existing codefeatureNew functionality or improvementNew functionality or improvement