Shared helpers for MishkaGervaz.Form.Web.Events and its sub-handlers.
Two reasons these live here rather than inside each sub-handler's
__using__ macro:
- Reuse across sub-handlers and user overrides. A user module that
overrides
submit/3(viause Events.SubmitHandler) can call any helper here without redefining it. - Smaller compiled bytecode per consumer. Pure helpers compile once in this module rather than into every consumer's beam.
Three groups:
- Typed-param helpers (
parse_typed_params/2,sanitize_typed_params/2) — dispatch throughfield.type_modulewhen set; pass through otherwise. - Sanitization helpers (
sanitize_string/1,sanitize_list_item/2) — extracted fromSanitizationHandler's__using__macro. - Upload helpers (
merge_uploaded_files/4) — extracted fromSubmitHandler's__using__macro.
See MishkaGervaz.Form.Web.Events,
MishkaGervaz.Form.Web.Events.SanitizationHandler,
MishkaGervaz.Form.Web.Events.SubmitHandler,
MishkaGervaz.Form.Web.Events.ValidationHandler, and the sibling
sub-handlers.
Summary
Functions
Runs each field's FieldType.validate/2 over params and returns a list
of {field_atom, message} pairs ready to merge into an AshPhoenix.Form's
errors keyword list. Fields whose type module doesn't implement
validate/2 (detected via the cached :custom_validate? flag) are
skipped.
Functions
Runs each field's FieldType.validate/2 over params and returns a list
of {field_atom, message} pairs ready to merge into an AshPhoenix.Form's
errors keyword list. Fields whose type module doesn't implement
validate/2 (detected via the cached :custom_validate? flag) are
skipped.