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

    Module dictionary

    Dictionary shape and factories.

    Defines shapes and factories for validating language-tagged string values, mapping JSON-LD language maps to RDF 1.1 language-tagged strings.

    Whether each tag holds a single string or a string array is determined by the cardinality of the enclosing SetShape, not by the shape itself:

    • Scalar cardinality (maxCount === 1): each tag holds a single string
    • Array cardinality (maxCount > 1 or unbounded): each tag holds a string array

    The tag-keyed map is the form stored and ingested. A localised property additionally coalesces under language negotiation when retrieved, at its per-tag cardinality: its template slot also accepts a coalesced placeholder for the negotiated value(s) (a bare string for single-string-per-tag, a single-element string array for array-per-tag), and a selection may constrain it with a plain-string operand (comparison, text search, or option) matched existentially over the coalesced value set under ordinary string semantics. State ingress never coalesces: it accepts only the tag-keyed form.

    Compatibility

    JSON JSON-LD RDF 1.1
    tag-keyed string map @language-container language map language-tagged string literals

    Defining Language-Tagged Shapes

    Models are tag-keyed maps; the und tag carries content of undetermined language (a proper name, say), and the zxx tag content with no language at all (identifiers, codes, formulae):

    import { required, optional, multiple } from '@metreeca/blue/value';
    import { dictionary } from '@metreeca/blue/dictionary';

    const label = required(dictionary()); // scalar, default model: { "*": "" }
    const title = required(dictionary({ und: "Untitled" })); // scalar with default content
    const name = required(dictionary({ minLength: 1, maxLength: 200 })); // constrained scalar
    const description = optional(dictionary({ languageIn: ["en", "it"] })); // language-restricted scalar
    const keywords = multiple(dictionary({ languageIn: ["en"] })); // array per tag

    Using in Resource Shapes

    import { required, optional, multiple } from '@metreeca/blue/value';
    import { dictionary } from '@metreeca/blue/dictionary';
    import { resource } from '@metreeca/blue/resource';

    const Article = resource({
    title: required(dictionary({ minLength: 1 })),
    abstract: optional(dictionary()),
    keywords: multiple(dictionary({ languageIn: ["en", "fr", "de"] }))
    });

    Interfaces

    DictionaryShape

    Shape definition for language-tagged string values.

    DictionaryConstraints

    Constraints for the dictionary shape factory.

    Functions

    dictionary

    Creates a dictionary shape.