• Checks if the given value is a valid Dayjs duration not longer than maximum.

    The minimum can be given as either:

    • a Dayjs duration
    • an ISO 8601 string, e.g. "PT1H"
    • a units object, e.g. { hour: 1, minute: 30 }
    • a time/unit tuple, e.g. [1, 'hour]
    // Ensure the value is a duration at most 1 hour long
    @MaxDuration([1, 'hour'], { inclusive: true })
    value: Duration

    Parameters

    • maximum:
          | string
          | Duration
          | Partial<
              {
                  days: number;
                  hours: number;
                  milliseconds: number;
                  minutes: number;
                  months: number;
                  seconds: number;
                  weeks: number;
                  years: number;
              },
          >
          | [time: number, unit?: DurationUnitType]

      The maximum allowed value.

    • Optionaloptions: { inclusive?: boolean } & ValidationOptions

      Accepts the following options (in addition to generic class-validator options):

      • inclusive: boolean = false If true, allow the maximum duration as well.

    Returns PropertyDecorator