Transpiles Ash resource validations (from validations do block) to client-side validation.
Unlike ConstraintTranspiler which reads type constraints on attributes, this module reads explicit validations which support custom messages.
Example
In your Ash resource:
validations do
validate present(:card_number), message: "Enter a card number"
validate string_length(:card_number, min: 15, max: 16), message: "Enter a valid card number"
endThese messages will be used in client-side validation instead of the generic defaults.
Summary
Functions
Extracts validations for a specific action from an Ash resource.
Gets the custom message for a validation, or generates a default.
Checks if a resource has any custom-message validations we should use.
Functions
Extracts validations for a specific action from an Ash resource.
Returns a map of field_name => list of validation specs. Each validation spec contains:
- :type - the validation type (:present, :string_length, etc.)
- :opts - validation options (min, max, etc.)
- :message - custom message (or nil for default)
Gets the custom message for a validation, or generates a default.
Supports interpolation of variables like %{min}, %{max}.
Checks if a resource has any custom-message validations we should use.
Returns true if there are validations with custom messages that would override the default constraint transpiler messages.