Attesto.MapParams (Attesto v1.12.0)

Copy Markdown View Source

Shared helpers for reading and validating protocol map parameters.

Wallet builders and parsers use these helpers at the boundary where caller input may use atom or string keys. The helpers keep that boundary behavior consistent while protocol-specific validation remains with each caller.

Summary

Functions

Return a keyword list or raise an ArgumentError.

Fetch a value by atom key, falling back to its string spelling.

Return a non-empty binary or raise an ArgumentError.

Put value into map unless it is nil.

Put a normalized non-nil value into map.

Raise unless value is a non-empty binary.

Convert atom keys in a map to strings, without recursing into values.

Return a list of binaries or raise an ArgumentError.

Functions

ensure_keyword!(opts)

@spec ensure_keyword!(term()) :: keyword()

Return a keyword list or raise an ArgumentError.

fetch(map, key)

@spec fetch(map(), atom()) :: term() | nil

Fetch a value by atom key, falling back to its string spelling.

optional_string!(value, key)

@spec optional_string!(term(), term()) :: String.t()

Return a non-empty binary or raise an ArgumentError.

put_optional(map, key, value)

@spec put_optional(map(), term(), term()) :: map()

Put value into map unless it is nil.

put_optional(map, key, value, normalizer)

@spec put_optional(map(), term(), term(), (term(), term() -> term())) :: map()

Put a normalized non-nil value into map.

required_string!(value, key)

@spec required_string!(term(), term()) :: String.t()

Raise unless value is a non-empty binary.

string_keyed_map(value)

@spec string_keyed_map(map()) :: map()

Convert atom keys in a map to strings, without recursing into values.

string_list!(value, key)

@spec string_list!(term(), term()) :: [String.t()]

Return a list of binaries or raise an ArgumentError.