-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
isISO8601
doesn't support duration
#2379
Comments
ISO 8601 is indeed a large spec with various features, that might not fit in a single validator. Can you elaborate a bit on why you would want to validate duration input and why it would be a good addition to this project? |
I can try :) Currently this library doesn't support duration inputs - I was unable to find a suitable validator ^P(?!$)(\d+(?:\.\d+)?Y)?(\d+(?:\.\d+)?M)?(\d+(?:\.\d+)?W)?(\d+(?:\.\d+)?D)?(T(?=\d)(\d+(?:\.\d+)?H)?(\d+(?:\.\d+)?M)?(\d+(?:\.\d+)?S)?)?$ And that only handles the As to why someone would want to use ISO 8601 duration is because it's a simple why to describe a duration 😄 and it's an ISO standard. It's not concerned with time zones. It's a simple way to describe; 5 min, 1 hour or 1 day, etc |
I'm having this issue too. In my use case, I need to describe media objects like audio/video which have a length defined as a duration. Recommend adding an |
isISO8601
appears to only check dates. But the ISO 8601 spec includes a bunch of different formats.validator.js/src/lib/isISO8601.js
Line 39 in 4197b86
The
isISO8601
validator name is a bit misleading as it suggests that it support the entire ISO 8601 spec. I discovered this wanting to use it to validate an ISO 8601 duration input, example:P3Y6M4DT12H30M5S
.So I'd like to request support for ISO 8601 durations.
I'd humbly suggest a name change for this validator. It can be split into
isISO8601Date
,isISO8601Duration
, etcThe text was updated successfully, but these errors were encountered: