Open erin-doyle opened 3 years ago
I agree that isoDuration()
doesn't support the full standard 👍 I think comprehensive support for fractions could be a little bit tricky to achieve just by tweaking the regex, since the fractional part can only appear in the smallest value. Partial support for fractions of seconds seems pretty simple to add since seconds are always the smallest value if they're present.
I think the open questions here are:
In the meantime it could be useful to experiment writing a joi exension to get this working!
Support plan
Context
What are you trying to achieve or the steps to reproduce?
When using the
isoDuration
type a ValidationError is thrown withmust be a valid ISO 8601 duration
when using a decimal value for the Seconds (for example: PT4.4S). Per the standard this should be a valid value:"The smallest value used may also have a decimal fraction[citation needed], as in "P0.5Y" to indicate half a year. This decimal fraction may be specified with either a comma or a full stop, as in "P0,5Y" or "P0.5Y". "
But it looks like the regex does not allow for it:
internals.isoDuration = /^P(?!$)(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?$/;
What was the result you got?
ValidationError: videoDuration: "videoDuration" must be a valid ISO 8601 duration
What result did you expect?
The Update to be successful.