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
Result is incorrect #42
Comments
|
Regarding 2: The |
From my point of view (a user, who uses the library from time to time, but not on everyday basis) this behavior is not obvious, is it a good practice for joi to change the type? |
It is standard behaviour for Joi to change the type, unless the This specific module extends the base |
Joi schemas, unless instructed otherwise, describe the types you get in the end, not the types you receive. Moment is used for parsing, that's it, the contract to get a date still stands. This behavior is mentioned on the very 1st sentence of the date type documentation, I'm not sure we can do much more than that for casual users such as yourself if you don't read the docs 🤷🏻♂️ If you want more granular control on those fields, you can also use https://joi.dev/api/?v=17.6.0#anyrawenabled, which will both validate and give you the original string. You can also create your extension to get moment objects as suggested by Gil if that's what you want. To me, this representation is as good as any, as a date or a string won't give you correct results either unless you have the location. |
A Date object is not a string. The fact that the validation does not fail in this case means this library is validating a "date string". Perhaps this module should be renamed to Joi.dateString() or documentation could be made clearer. For anyone looking for actual Date validation, I have found that this seems to work:
|
Context
What are you trying to achieve or the steps to reproduce?
What was the result you got?
What result did you expect?
So I see 2 issues here:
The text was updated successfully, but these errors were encountered: