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

    Function dictionary

    Creates a dictionary shape.

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

      Type Parameters

      • M extends { readonly [tag: string]: string }

        The scalar Locales type of the model

      Parameters

      • model: M

        Scalar localised prototype value for runtime model assembly: a tag-keyed map associating each language tag (or tag range) with its content

      Returns Omit<DictionaryShape, "model"> & { model: M }

      An immutable shape with model typed as M

      If model is not a uniform tag-keyed map of either single strings or singleton string tuples, or if any of its keys is not a basic language range

      const title = dictionary({ en: "Untitled", it: "Senza titolo" } as const);
      const name = dictionary({ und: "Default" }); // language-neutral content under `und`
    • Creates a dictionary shape with optional validation constraints.

      Type Parameters

      Parameters

      Returns DictionaryShape

      An immutable shape with model typed as Locales

      If constraints contains contradictory values

      const label = dictionary();
      const name = dictionary({ minLength: 1, maxLength: 100 });
      const restricted = dictionary({ languageIn: ["en", "it"] });