Sinter.Transform (Sinter v0.3.1)

Copy Markdown View Source

Lightweight serialization helpers for request payloads.

  • Drops Sinter.NotGiven/Sinter.NotGiven.omit/0 sentinels
  • Applies key aliases and simple formatters (e.g., ISO8601 timestamps)
  • Recurses through maps, structs, and lists while stringifying keys

Summary

Functions

Transform a payload into a JSON-friendly map.

Types

format()

@type format() :: :iso8601 | (term() -> term())

opts()

@type opts() :: [
  aliases: map(),
  formats: map(),
  drop_nil?: boolean(),
  schema: Sinter.Schema.t() | nil,
  use_aliases: boolean()
]

Functions

transform(data, opts \\ [])

@spec transform(term(), opts()) :: term()

Transform a payload into a JSON-friendly map.

  • Keys are stringified and alias mappings are applied
  • NotGiven/omit sentinels are removed
  • Optional formatters can be attached per key (:iso8601 or a unary function)

Options

  • :aliases - Map of canonical keys to alias keys
  • :formats - Map of keys to formatters
  • :drop_nil? - Whether to drop nil values (default: false)
  • :schema - A Sinter.Schema to extract aliases from
  • :use_aliases - Whether to use aliases from schema (default: false)