BlogEngine.AcceptedAttrs (blog_engine v0.1.0)

Copy Markdown View Source

Selects submitted attributes from string- or atom-keyed maps, honoring clearable fields.

Summary

Functions

Fetches field from attrs under its atom key, then its string key.

Takes the submitted fields from attrs, keeping atom keys.

Functions

fetch(attrs, field)

@spec fetch(map(), atom()) :: {:ok, term()} | :error

Fetches field from attrs under its atom key, then its string key.

Returns {:ok, value} when either key is present and :error otherwise.

take(attrs, fields, clearable_fields)

@spec take(map(), [atom()], [atom()]) :: map()

Takes the submitted fields from attrs, keeping atom keys.

An absent field is omitted. An explicit nil is kept only when the field is listed in clearable_fields; otherwise the nil submission is dropped.