Skip to content

feature: add IsDurationString to validate duration strings #2613

Description

@os-moussao

Description

I would like to have an IsDurationString decorator that validates duration strings ("1 Day", "2 weeks", "7 hrs"...) from the ms package, exactly the ms.StringValue type.

An IsDuration decorator could be considered too, which validates for either a positive integer (milliseconds) or a duration string. (basically, the value is valid to pass to the ms function).

Proposed solution

Implementation of the validator could be either:

  • Having ms library as a dependency: try converting the value through ms, if it succeeds then the value is valid.
  • Implementing an ms-like parser for validation, without adding a dependency.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    flag: needs discussionIssues which needs discussion before implementation.type: featureIssues related to new features.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions