Corex. Value
(Corex v0.2.0)
View Source
Coercions for the values that reach a component from outside the library.
Imperative API calls carry values that often originate in handle_event
params, so a bad value is bad user input as often as it is a developer
mistake. Every function here coerces and warns rather than raising: dropping
the value keeps the LiveView alive, where raising would take the whole process
down mid-render.
Summary
Types
A value an imperative API accepts without narrowing it first.
Functions
Coerces a value to a list of strings silently, for internal callers that already reported the problem or have no context to report it with.
Coerces a value to a list of strings, warning and returning [] otherwise.
Coerces a single-selection value to a string or nil, warning on anything else.
Parses an imperative API value that may arrive as a list or a delimited string.
Types
@type coercible() :: term()
A value an imperative API accepts without narrowing it first.
Any term, because the guard is deliberately absent: these functions coerce and warn, so a spec that named only the useful shapes would claim a check the function does not perform.
Functions
Coerces a value to a list of strings silently, for internal callers that already reported the problem or have no context to report it with.
Coerces a value to a list of strings, warning and returning [] otherwise.
Coerces a single-selection value to a string or nil, warning on anything else.
Parses an imperative API value that may arrive as a list or a delimited string.
With graphemes: true a string without commas is split per grapheme, which is
what pin input expects. Anything unparseable is coerced to [] with a warning.