Documentation
    Preparing search index...

    Interface IProps<Target, Kind, Value, Validate, Exclusive, Schema>

    Configuration interface for validation tag properties.

    Defines all the metadata a validation tag can specify, including what types it applies to, how to validate values, and what to output in JSON Schema.

    interface IProps<
        Target extends
            "boolean"
            | "bigint"
            | "number"
            | "string"
            | "array"
            | "object",
        Kind extends string,
        Value extends boolean | bigint | number | string | undefined,
        Validate extends string | { [key in Target]?: string },
        Exclusive extends boolean | string[],
        Schema extends object | undefined,
    > {
        exclusive?: string[] | Exclusive;
        kind: Kind;
        schema?: Schema;
        target: Target;
        validate?: Validate;
        value: Value;
    }

    Type Parameters

    • Target extends "boolean" | "bigint" | "number" | "string" | "array" | "object"

      Which primitive type(s) this tag can be applied to

    • Kind extends string

      Unique identifier for this tag type

    • Value extends boolean | bigint | number | string | undefined

      The constraint value specified by the user

    • Validate extends string | { [key in Target]?: string }

      The validation expression to generate

    • Exclusive extends boolean | string[]

      Whether this tag conflicts with others

    • Schema extends object | undefined

      Additional JSON Schema properties to output

    Index

    Properties

    exclusive?: string[] | Exclusive

    Tag exclusivity configuration.

    Controls which other tags cannot be combined with this one:

    • true: No duplicate tags of the same kind allowed
    • string[]: List of incompatible tag kinds
    • false (default): No exclusivity restrictions

    For example, Minimum and ExclusiveMinimum are mutually exclusive - only one can be applied to a property.

    false
    
    kind: Kind

    Unique identifier for this tag type.

    Used internally to identify the constraint kind. Examples: "minimum", "maxLength", "format", "pattern".

    schema?: Schema

    Additional JSON Schema properties to output.

    Object containing schema properties to merge into the generated JSON Schema for the annotated type. For Minimum<5>, this would be { minimum: 5 }.

    target: Target

    Target primitive type(s) this tag applies to.

    The transformer will error if the tag is applied to a property of a different type. For example, MinLength targets "string" and cannot be applied to numbers.

    validate?: Validate

    Validation expression template.

    JavaScript expression string that validates the input value. Use $input as a placeholder for the actual value. The expression is inserted into the generated validation function.

    Can be a single string or an object mapping target types to different expressions (for tags supporting multiple types).

    `"5 <= $input"`; // For Minimum<5>
    
    `"$input.length <= 10"`; // For MaxLength<10>
    
    value: Value

    User-configured constraint value.

    The value provided by the user when applying the tag. For Minimum<5>, this would be 5. For Format<"email">, this would be "email".