DoubleEntryLedger.Utils.Changeset (double_entry_ledger v0.3.0)
View SourceChangeset helpers for error formatting and custom validations.
Summary
Functions
Returns errors grouped by field as a map of lists of {message_template, opts} tuples.
Validates that trace_context is a flat string-valued map with a bounded
number of keys.
Functions
@spec all_errors(Ecto.Changeset.t()) :: String.t()
Returns errors grouped by field as a map of lists of {message_template, opts} tuples.
Messages are not interpolated; templates and their options are preserved for downstream formatting, translation, or logging.
@spec validate_trace_context(Ecto.Changeset.t(), atom()) :: Ecto.Changeset.t()
Validates that trace_context is a flat string-valued map with a bounded
number of keys.
The maximum number of keys defaults to 10 and can be overridden via application config:
config :double_entry_ledger, max_trace_context_keys: 20Rejects nested maps, non-string values, and oversized maps to prevent abuse while remaining vendor-neutral.
Examples
changeset
|> validate_trace_context(:trace_context)