-
Notifications
You must be signed in to change notification settings - Fork 91
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
Support for date-time, time string format. #337
Comments
@DonVietnam it's already done by "date" ? date with convert will just handled all the format from the Date constructor : MDN . So, ISO 8601 is already supported . with +00:00 ( Or I missunderstand ? |
No, I mean, exactly check if string contains date in ISO 8601 format, not any date string. Date constructor can accept many formats. |
Oh ! ok, you want to be precise on the check ? not "all what can be a date" ? ( did you have any use case ? ) . Else, you can maybe do it with a string, and a regex pattern ? |
Yes, I want to check the date for exact compliance with the format, the essence of such a check is to use the validation library, specifying the desired format to it, and then just put the incoming data in the database. Why do I need a data validation library if I'm going to write regular expressions for data validation myself or translate everything into a Date object, and then drag out the desired format from there myself. |
it can handle more than that . it can check multiples properties and return the object . ( and so "date" can be only one of the properties ), if you need it only for date validation, it's maybe not needed ? About your use case, ok ... but so, you just need to do |
I solved it using type string with a regex pattern |
Quite often, when developing an API, there is a need to work with time, the most popular input data format with this approach is ISO 8601 ( 2018-11-13T20:20:39+00:00), it would be great to add validation support for this format out of the box. This format supports the JSON Schema specifications and is called 'date-time', there are also two additional formats for 'time' and 'date', since in this case 'date' is already occupied, we can use the 'date-time' type, under which all three JSON Schema formats will fit, or call type 'date' as 'date-string'.
If support for this format has already been implemented and I just haven't found it, I apologize.
The text was updated successfully, but these errors were encountered: