Documentation
    Preparing search index...

    Type Alias MaxLength<Value>

    MaxLength: tags.TagBase<
        {
            exclusive: true;
            kind: "maxLength";
            schema: { maxLength: Value };
            target: "string";
            validate: `$input.length <= ${Value}`;
            value: Value;
        },
    >

    String maximum length constraint.

    MaxLength<N> is a type tag that validates string values have at most the specified number of characters. Apply it to string properties using TypeScript intersection types.

    This constraint is commonly combined with MinLength to define a valid length range. Multiple length constraints can be applied to the same property (all must pass).

    The constraint is enforced at runtime by typia.is(), typia.assert(), and typia.validate(). It generates maxLength in JSON Schema output.

    Type Parameters

    • Value extends number

      Maximum number of characters allowed

    Jeongho Nam - https://github.com/samchon

    interface Article {
    // Title limited to 100 characters
    title: string & MaxLength<100>;
    // Description between 10-500 characters
    description: string & MinLength<10> & MaxLength<500>;
    }