eclipsesource/play-json-schema-validator

date-time format validator is better if implemented via java.time.OffsetDateTime.parse

Closed this issue · 1 comments

Current date-time format validator misses few cases. I have created a test to try the following what I expect to fail validation of date-time format. Some do not fail.

I have found that the most reliable approach to validate the format is to use java.time.OffsetDateTime.parse() and catch the exception.

"2007-12-03T10:15:30",
"2007-12-03 10:15:30+01:00",
"2007-12-03 10:15:30",
"2007-12-03 10:15",
"2007-12-03",
"2007-12-03T10:15:30.1111111",
"99999-12-03T10:15:30+01:00",
"-00000-12-03T10:15:30+01:00",
"2007-12-32T10:15:30+01:00",
"2007-13-03T10:15:30+01:00",
"2007-12-03T25:15:30+01:00",
"2007-12-03T10:60:30+01:00",
"2007-12-03T10:15:60+01:00",
"2007-13-03T10:15:30+01:60",
"2007-12-03T10:15:30+20:00",
"2007-12-03T10:15:30+01:00.1",
"2007:12:03T10:15:30+01:00.1"

Thanks for reporting! I'll try to have a look this weekend.