Standalone validators that reuse a GuardedStruct schema without going
through the full builder/1 pipeline.
Three tiers:
run/2— derive op-string against a single value, no module needed.field/3,4— validate one named field of aguardedstructmodule. Cross-field dependencies (on:,domain:) honoured by mode.partial/2— validate a subset of fields together. Missing fields skipped (noenforce_keyscheck). Useful for form-as-you-type and PATCH-style endpoints.
Returns the validated value (or partial map) on success, an error list
with the same shape as builder/1 on failure.
Summary
Functions
Validate a single named field of a guardedstruct module.
Validate a partial map of fields. Missing fields are skipped (no
enforce_keys check). Cross-field deps resolve from the same input.
Validate a value against a derive op-string. No module needed.
Types
Functions
Validate a single named field of a guardedstruct module.
Modes
:strict(default) — honouron:anddomain:core keys. Errors if a cross-field dependency can't be resolved.:isolated— skip cross-field deps. Run onlyderive:+validator:.
Context
Pass context: %{other_field: ...} to provide values for cross-field
dependency resolution.
Validate a partial map of fields. Missing fields are skipped (no
enforce_keys check). Cross-field deps resolve from the same input.
Validate a value against a derive op-string. No module needed.
iex> GuardedStruct.Validate.run("validate(string, max_len=80)", "hi")
{:ok, "hi"}