Skip to content

date-time validation check using regex#413

Merged
gregsdennis merged 2 commits intojson-everything:schema/bundle-failure-itemsfrom
faldor20:Correct-validation-of-date-time
Mar 27, 2023
Merged

date-time validation check using regex#413
gregsdennis merged 2 commits intojson-everything:schema/bundle-failure-itemsfrom
faldor20:Correct-validation-of-date-time

Conversation

@faldor20
Copy link

DateTimes that have very high precision eg: 2023-03-20T05:41:23.802351665Z can be parsed by dotnet and are allowed by jsonschema but don't get accepted by TryParseExact
This uses regex as a fallback to check a datetime just incase it's actually compliant event though TryParseExact disagrees.

Copy link
Collaborator

@gregsdennis gregsdennis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like (line 19) that I only supply formats up to 7-digit precision. Have you tried adding the additional digits here instead of regex?

Also can you add a unit test to cover this case, please?

@faldor20
Copy link
Author

I did try that, unfortunately adding more does nothing.
https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings
It seems the list here is comprehensive.
I couldn't see where you were testing it in the first place so I wasn't quite sure where to add a test.
If you point me in the right direction I'll happily do so though :)

Thanks for getting back to me so quick!

@gregsdennis
Copy link
Collaborator

I couldn't see where you were testing it in the first place so I wasn't quite sure where to add a test.

Please add to FormatTests.

@faldor20 faldor20 requested a review from gregsdennis March 27, 2023 04:14
@gregsdennis gregsdennis changed the base branch from master to schema/bundle-failure-items March 27, 2023 21:58
@gregsdennis
Copy link
Collaborator

Thanks. I'm going to merge this into #418 just to combine releases.

@gregsdennis gregsdennis merged commit 21198b0 into json-everything:schema/bundle-failure-items Mar 27, 2023
@faldor20 faldor20 deleted the Correct-validation-of-date-time branch March 28, 2023 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants