@hyperjump/json-schema-errors
    Preparing search index...

    Type Alias KeywordDefinition<Value, Context>

    type KeywordDefinition<
        Value = unknown,
        Context extends EvaluationContext = EvaluationContext,
    > = {
        alias?: string;
        annotation?: true;
        conditional?: true;
        error?: (
            value: Value,
            localization: Localization,
            instance: JsonNode,
        ) => string;
        requirement?: (
            value: Value,
            localization: Localization,
        ) => string | undefined;
        evaluate?(
            value: Value,
            instance: JsonNode,
            context: Context,
        ): void | NormalizedOutput[];
    }

    Type Parameters

    Index
    alias?: string

    The URI of a keyword that means the same thing. The keyword's results are normalized under that URI, so everything that handles that keyword handles this one too. The compiled values must have the same shape. For example, the OpenAPI 3.0 type keyword is an alias of the JSON Schema type keyword.

    annotation?: true

    Annotations, such as title and description, never affect validation. A schema that only has annotations allows any value.

    conditional?: true

    Conditional applicators, like then and dependentSchemas, are simple applicators whose subschemas only apply when a condition holds. Whether a keyword is a simple applicator comes from its @hyperjump/json-schema keyword definition. The results of a simple applicator's subschemas are flattened into the results of its parent schema, but the results of a conditional applicator are left out when describing the parent schema because its error handler describes them along with the condition.

    error?: (value: Value, localization: Localization, instance: JsonNode) => string

    The message for an occurrence of the keyword that failed.

    Type Declaration

      • (value: Value, localization: Localization, instance: JsonNode): string
      • Parameters

        • value: Value

          The keyword's value as compiled by its @hyperjump/json-schema definition

        • localization: Localization
        • instance: JsonNode

          The value that failed

        Returns string

    requirement?: (value: Value, localization: Localization) => string | undefined

    What the keyword requires, or in a negated localization, what would make it fail. Use localization.formatRequirement to pick the message. Return undefined if the keyword doesn't require anything. It's used to explain failures caused by a subschema passing, such as with not.

    Type Declaration

      • (value: Value, localization: Localization): string | undefined
      • Parameters

        • value: Value

          The keyword's value as compiled by its @hyperjump/json-schema definition

        • localization: Localization

        Returns string | undefined

    • Applicators call evaluateSchema on each subschema and return an array with each result. Other keywords don't need this.

      Parameters

      Returns void | NormalizedOutput[]