@metreeca/blue - v0.9.1
    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 }

      A shape with model typed as M

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

      Parameters

      Returns StringShape

      A shape with model typed as string

      If constraints is not a valid StringConstraints

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