Response validation: Automatically coerce date data type to ISO string
See original GitHub issueIs your feature request related to a problem? Please describe.
When validating responses, if the data type is a js Date
object, the validation of type string with format date-time fails.
{
updatedAt: new Date() // fails
}
{
updatedAt: "2010-13-30T23:12:35Z" // passes
}
Describe the solution you’d like The lib should try to coerce the type to ISO string and then try validation on it.
{
updatedAt: new Date() // should pass
}
Describe alternatives you’ve considered
I have to programmatically search through all the object to find a date data type and call the toISOString
method on it to pass the output validation.
Additional context None
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Yup.date() convert date into string without timezone after ...
When I type the date in the inputs, the validation is working perfectly but the date is being returned in the format 2021-03-31T18:30:00.000Z...
Read more >JavaScript JSON Date Parsing and real Dates - Rick Strahl
One way around this date problem is to extend the JSON parser to automatically convert the ISO string dates into real JavaScript dates....
Read more >7. Validation, Data Binding, and Type Conversion - Spring
Spring 3 introduces a "core.convert" package that provides a general type ... For example, a Date can be represented in a human readable...
Read more >Using automatic recognition with DATEFORMAT and ...
Describes how to automatically recognize and convert the date format or time format in your source data.
Read more >Extra Data Types - FastAPI
Other data types¶ · Python datetime.date . · In requests and responses will be represented as a str in ISO 8601 format, like:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
this is solved in
v4.10.0
, please give it a try@pilerou has provided an option that will help solve this. please have a look at https://github.com/cdimascio/express-openapi-validator/pull/493 and provide feedback. thanks!