# ValidDuration

`type` in `utils` · v0.10.0

<https://seedcord.org/docs/packages/utils/0.10.0/types/valid-duration>

A duration string that [`parseDuration`](/docs/packages/utils/0.10.0/functions/parse-duration) accepts, like `'30m'`, `'24h'`, or `'500ms'`. It's a
whole number above 0, followed by one of the units `ms`, `s`, `m`, `h`, or `d`.

Use it to make your own function reject a bad duration at compile time. A call like `every('1.5h')` then fails to compile, and the error explains what a duration
looks like. A value typed as `string`, like one from `.env`, still compiles. Check it with
`parseDuration` at run time.

## Examples

```ts
declare function every<const TText extends string>(duration: ValidDuration<TText>): void;

every('90s');
every('1.5h'); // fails to compile
```

## Declaration

```ts
type ValidDuration<TText extends string> =
    string extends TText ? TText : EachDuration<TText>;
```
