@grafctory/blue - v0.17.0
    Preparing search index...

    Function string

    Creates a string shape.

    • Creates a string shape.

      Contradictory constraints are rejected as the shape is built, so a shape that exists admits at least one value.

      Type Parameters

      • const C extends StringConstraints = {}

        The stated constraints

      • D extends Optional<Reference> = undefined

        The stated datatype, undefined where the constraints have no datatype to state

      Parameters

      • Optionalconstraints: C & { datatype?: D }

        Optional shape constraints

      Returns StringShape<{ inferred V }, D>

      An immutable shape admitting the strings the constraints bound, narrowed to the values they enumerate and typed with the datatype they state. A shape stating no datatype also qualifies as the content of a dictionary, which holds localised text to the same rules as a plain value

      TraceError Where the stated constraints contradict one another

    • Creates a string shape admitting an enumerated set of values.

      Reads bare strings as the enumeration closing the domain to them, so that a set of admitted values is stated as string("open", "closed") rather than as string({ in: ["open", "closed"] }).

      Type Parameters

      • const V extends readonly string[]

        The values the shape admits

      Parameters

      • ...values: V

        The admitted values

      Returns StringShape<V[number], undefined>

      An immutable shape admitting values alone, stating no datatype