> For the complete documentation index, see [llms.txt](https://type.angular-package.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://type.angular-package.dev/type/stringoflength.md).

# StringOfLength

## `StringOfLength<Min, Max, Type>`

A [`string`](https://www.typescriptlang.org/docs/handbook/basic-types.html#string) type or an instance of [`String`](https://www.typescriptlang.org/docs/handbook/basic-types.html#string) of length between a specified range takes generic type variable [`Min`](#minextendsnumber) and [`Max`](#max-extends-number) constrained by [`number`](https://www.typescriptlang.org/docs/handbook/basic-types.html#number) type as length, and takes generic type variable [`Type`](#typeextendsanystring-string) constrained by generic type [`AnyString`](/type/anystring.md) as the type.

{% code title="string-of-length.type.ts" %}

```typescript
type StringOfLength<
  Min extends number,
  Max extends number,
  Type extends AnyString = string
> = Type & MinMax<Min, Max>;
```

{% endcode %}

### Generic type variables

#### <mark style="color:green;">`Min`</mark>`extends`<mark style="color:green;">`number`</mark>

A generic type variable `Min` constrained by the [`number`](https://www.typescriptlang.org/docs/handbook/basic-types.html#number) type indicates the **minimum** length of the generic type variable [`Type`](#typeextendsanystring-string).

#### <mark style="color:green;">`Max`</mark>`extends`<mark style="color:green;">`number`</mark>

A generic type variable `Max` constrained by the [`number`](https://www.typescriptlang.org/docs/handbook/basic-types.html#number) type indicates the **maximum** length of the generic type variable [`Type`](#typeextendsanystring-string).

#### <mark style="color:green;">`Type`</mark>`extends`<mark style="color:green;">`AnyString`</mark>`=`<mark style="color:green;">`string`</mark>

A generic type variable `Type` constrained by generic type [`AnyString`](/type/anystring.md) indicates [`string`](https://www.typescriptlang.org/docs/handbook/basic-types.html#string) type.
