Executes compiled Schema rules against data, accumulating errors and tracking
evaluated keys for unevaluatedProperties/unevaluatedItems.
During validation, a context tuple is threaded through each rule:
{path, evaluated_keys, validation_context}path— Reversed list of JSON Pointer segments (e.g.,["email", 0, "users"])evaluated_keys—MapSetof property names or array indices validated so farvalidation_context—ValidationContextstruct referencing the root schema
Examples
iex> {:ok, schema} = JSONSchex.compile(%{"type" => "object", "properties" => %{"name" => %{"type" => "string"}}})
iex> JSONSchex.Validator.validate(schema, %{"name" => "Alice"})
:ok
Summary
Functions
Validates data against a compiled schema.
Recursive validation engine called by the rule dispatcher.
Functions
@spec validate(JSONSchex.Types.Schema.t(), term()) :: :ok | {:error, [JSONSchex.Types.Error.t()]}
Validates data against a compiled schema.
Examples
iex> {:ok, schema} = JSONSchex.compile(%{"type" => "integer", "minimum" => 0})
iex> JSONSchex.Validator.validate(schema, 10)
:ok
iex> {:ok, schema} = JSONSchex.compile(%{"type" => "integer", "minimum" => 0})
iex> {:error, errors} = JSONSchex.Validator.validate(schema, -5)
iex> Enum.any?(errors, fn e -> e.rule == :minimum end)
true
@spec validate_entry( JSONSchex.Types.Schema.t(), term(), list(), JSONSchex.Types.ValidationContext.t(), term() ) :: {:ok, MapSet.t()} | {:error, [JSONSchex.Types.Error.t()] | String.t()}
Recursive validation engine called by the rule dispatcher.
Executes all rules in the schema sequentially, accumulating errors and evaluated keys.
Examples
iex> {:ok, schema} = JSONSchex.compile(%{"type" => "string"})
iex> ctx = %JSONSchex.Types.ValidationContext{root_schema: schema, scope_stack: [], source_id: nil, raw: nil}
iex> JSONSchex.Validator.validate_entry(schema, "hello", [], ctx)
{:ok, MapSet.new()}