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

    Function validate

    Validates a value against a shape.

    • Validates a value against a shape.

      Performs structural validation using isValue, then enforces all shape constraints. For ResourceShape, this includes cardinality, closed-shape checks, and custom validators — unknown and missing properties are both rejected.

      Type Parameters

      • T extends Value

        The value type inferred from shape

      Parameters

      • value: unknown

        The value to validate

      • shape: Lazy<ValueShape & { model: T }>

        The ValueShape defining validation constraints; may be a Lazy factory

      • Optionalopts: { mode: "value" }

        Optional validation options

        • Readonlymode: "value"

          Must be "value"

      Returns Relay<{ value: T; trace: Trace }>

      A Relay resolving to either { value } on success or { trace } on failure

      Idempotent for object values: calling multiple times on the same branded object with the same mode returns the same reference.

    • Validates a partial resource update against a shape.

      Performs structural validation using isPatch, accepting null property values as deletion markers. The id property is required when defined in the shape. Enforces constraints on properties present in the payload — missing regular properties are accepted as not modified.

      Type Parameters

      • T extends Patch

        The patch type inferred from shape

      Parameters

      • value: unknown

        The value to validate

      • shape: Lazy<ResourceShape>

        The ResourceShape defining validation constraints; may be a Lazy factory

      • opts: { mode: "patch" }

        Validation options

        • Readonlymode: "patch"

          Must be "patch"

      Returns Relay<{ value: T; trace: Trace }>

      A Relay resolving to either { value } on success or { trace } on failure

      Idempotent for object values: calling multiple times on the same branded object with the same mode returns the same reference.

    • Validates a query/projection model against a shape.

      Performs structural validation using isModel. Value constraints and custom validators are skipped as a model describes a projection shape rather than actual data. Cardinality is checked only for shape consistency (scalar if maxCount is 1, singleton tuple otherwise). Unknown properties are rejected, but missing properties are accepted as not requested.

      Type Parameters

      • T extends Model

        The model type inferred from shape

      Parameters

      • value: unknown

        The value to validate

      • shape: Lazy<ResourceShape>

        The ResourceShape defining validation constraints; may be a Lazy factory

      • opts: { mode: "model"; depth?: number | null }

        Validation options

        • Readonlymode: "model"

          Must be "model"

        • Optional Readonlydepth?: number | null

          Maximum nesting depth for reference and embedded resource expansion; 0 rejects any nested model or query while still accepting IRI references; null for unlimited; defaults to 0

      Returns Relay<{ value: T; trace: Trace }>

      A Relay resolving to either { value } on success or { trace } on failure

      Idempotent for object values: calling multiple times on the same branded object with the same mode returns the same reference.

    • Validates a query with filtering, ordering, and pagination criteria against a shape.

      Performs structural validation using isQuery. Projection properties are validated for existence and type compatibility against the shape. Operator-prefixed filter and ordering keys are validated to ensure referenced expressions resolve to properties defined in the shape. Pagination keys are accepted structurally. Value constraints and custom validators are skipped as queries describe projection shapes rather than actual data.

      Type Parameters

      • T extends Query

        The query type inferred from shape

      Parameters

      • value: unknown

        The value to validate

      • shape: Lazy<ResourceShape>

        The ResourceShape defining validation constraints; may be a Lazy factory

      • opts: { mode: "query"; depth?: number | null }

        Validation options

        • Readonlymode: "query"

          Must be "query"

        • Optional Readonlydepth?: number | null

          Maximum nesting depth for reference and embedded resource expansion; 0 rejects any nested model or query while still accepting IRI references; null for unlimited; defaults to 0

      Returns Relay<{ value: T; trace: Trace }>

      A Relay resolving to either { value } on success or { trace } on failure

      Idempotent for object values: calling multiple times on the same branded object with the same mode returns the same reference.