Packages

Reference Elixir validator for WPL (Wellness Plan Language) — JSON Schema + semantic invariants

Current section

Files

Jump to
wpl_validator lib wpl validator error.ex
Raw

lib/wpl/validator/error.ex

defmodule WPL.Validator.Error do
@moduledoc """
A single validation finding.
Fields:
* `:path` — RFC 6901 JSON Pointer to the offending node (string).
* `:code` — atom, e.g. `:duplicate_id` or `:schema_violation`.
* `:message` — human-readable description.
* `:severity` — `:error` or `:warning`.
* `:meta` — code-specific extra fields (map, may be empty).
* `:repair_hint` — optional structured guidance for agentic repair.
See `WPL.Validator.RepairHint` for the shape.
"""
@type code ::
:schema_violation
| :duplicate_id
| :unresolved_ref
| :catalog_required
| :empty_phases_for_type
| :invalid_prescription
| :invalid_personalization_rule
| :invalid_points_rule
| :phase_duration_mismatch
| :cyclic_subplan
| :activity_block_mismatch
| :goal_category_off_vocab
| :dietary_tags_off_vocab
@type severity :: :error | :warning
@type t :: %__MODULE__{
path: String.t(),
code: code(),
message: String.t(),
severity: severity(),
meta: map(),
repair_hint: WPL.Validator.RepairHint.t() | nil
}
@enforce_keys [:path, :code, :message, :severity]
defstruct [:path, :code, :message, :severity, meta: %{}, repair_hint: nil]
end