Builds validation results and evaluates declarative field rules.
Field rules come from field/3 options in a schema block (required, min_length,
max_length, email, matches, min, max, greater_than, less_than). The same rules
are written into the generated TypeScript validators, so the browser rejects what the server
would reject.
A command can add cross-field rules by defining validate/2, returning :ok or
{:error, results} built with error/2.
Summary
Functions
Builds an error result for the given members.
The client-visible rule descriptors for a field's options, as %{name: "minLength", args: [3]}.
Evaluates the declarative rules of every field in fields against struct.
Builds a warning result.
Functions
@spec error(String.t(), [atom() | String.t()], keyword()) :: Arc.ValidationResult.t()
Builds an error result for the given members.
Arc.Validation.error("Already registered", [:name])
The client-visible rule descriptors for a field's options, as %{name: "minLength", args: [3]}.
@spec validate_fields(struct(), [Arc.Schema.Field.t()]) :: [Arc.ValidationResult.t()]
Evaluates the declarative rules of every field in fields against struct.
@spec warning(String.t(), [atom() | String.t()], keyword()) :: Arc.ValidationResult.t()
Builds a warning result.