@metreeca/blue - v0.10.0
    Preparing search index...

    Function string

    Creates a string shape.

    • Creates a string shape with a typed model value and no other constraints.

      Type Parameters

      • M extends string

        The literal string type for the model

      Parameters

      • model: M

        Prototype value for runtime model assembly

      Returns StringShape & { model: M }

      An immutable shape with model typed as M

      const status = string("active" as const);
      
    • Creates a string shape with optional validation constraints.

      Type Parameters

      Parameters

      Returns StringShape

      An immutable shape with model typed as string

      If constraints contains contradictory values

      const value = string();
      const name = string({ minLength: 1, maxLength: 100 });
      const code = string({ model: "ABC-1234", pattern: /^[A-Z]{3}-\d{4}$/ });