json-schema icon indicating copy to clipboard operation
json-schema copied to clipboard

DateTimeFormats::duration seems to be buggy

Open taraghi opened this issue 1 year ago • 0 comments

Hi,

The regular expression defined in the class DateTimeFormats does not cover ISO 8601 encoded duration.

For example a duration like P2Y1D is not recognized as valid.

As far as I see the following regex should be rather applied for the format check:

^P(?!$)(\d+(?:\.\d+)?Y)?(\d+(?:\.\d+)?M)?(\d+(?:\.\d+)?W)?(\d+(?:\.\d+)?D)?(T(?=\d)(\d+(?:\.\d+)?H)?(\d+(?:\.\d+)?M)?(\d+(?:\.\d+)?S)?)?$

Thanks

taraghi avatar Feb 21 '24 14:02 taraghi