Lavash.ExtendErrors (Lavash v0.4.0-rc.1)

Copy Markdown View Source

Extends auto-generated form field errors with custom error checks.

Used to add custom validation rules beyond what Ash resource constraints provide. The custom errors are merged with Ash-generated errors and visibility is handled automatically via JS touched/submitted tracking.

Fields

  • :field - The field errors to extend (e.g., :registration_email_errors)
  • :errors - List of {condition_rx, message} tuples

Usage

extend_errors :registration_email_errors do
  error rx(not String.contains?(@registration_params["email"] || "", "@")), "Must contain @"
end

This merges the custom error with the auto-generated Ash errors when the condition is true (i.e., when the field is invalid).