PtcRunner.Kernel.SchemaViolation (PtcRunner v0.14.0)

Copy Markdown View Source

Bounded, value-free projection of a JSON Schema validation failure.

Validator errors may retain the rejected document, caller-authored property names, schema internals, and every rejected branch of a tagged union. This projection keeps only a closed rule atom and a path explained by the schema that rejected the document. Missing required properties may extend the validator's parent path only when the schema authorizes the missing name; unknown properties never retain their caller-authored key.

For a rejected oneOf, the branch with no discriminator failure and the smallest bounded error set wins. This keeps a tagged installation's real failure instead of reporting the unrelated required fields or closed keys of every other installation variant.

Summary

Functions

Projects one JSV error list through the schema that rejected it.

Builds a bounded violation from an already schema-authorized path.

Validates one value, retries one timeout, and distinguishes unavailable bounded work.

Types

rule()

@type rule() ::
  :const
  | :contains
  | :duplicate_property
  | :enum
  | :max_items
  | :max_length
  | :max_properties
  | :maximum
  | :min_items
  | :min_length
  | :min_properties
  | :minimum
  | :multiple_of
  | :not
  | :one_of
  | :pattern
  | :required
  | :schema
  | :type
  | :unique_items
  | :unknown_property

t()

@type t() :: %PtcRunner.Kernel.SchemaViolation{
  path: [PtcRunner.Kernel.CommandPath.segment()],
  rule: rule()
}

unavailable_reason()

@type unavailable_reason() :: :timeout | :cancelled | :heap_exceeded | :worker_failed

Functions

from_jsv(errors, schema)

@spec from_jsv([term()], map()) :: t()

Projects one JSV error list through the schema that rejected it.

new(rule, path)

Builds a bounded violation from an already schema-authorized path.

validate(value, schema)

@spec validate(term(), map()) ::
  :ok | {:error, t()} | {:unavailable, unavailable_reason()}

Validates one value, retries one timeout, and distinguishes unavailable bounded work.