PUI.Components (pui v1.0.0-beta.11)

Copy Markdown

Summary

Functions

Renders form field error messages.

Translates a form error tuple into a human-readable string.

Functions

badge(assigns)

Attributes

  • class (:string) - Defaults to "".
  • variant (:string) - Defaults to "default". Must be one of "default", "secondary", "destructive", or "outline".

Slots

  • inner_block

field_error(assigns)

Renders form field error messages.

Displays validation errors below form inputs. Renders nothing when errors is empty.

Examples

<.field_error errors={["can't be blank"]} />
<.field_error errors={["must be at least 3 characters", "is invalid"]} />
<.field_error errors={[]} />

Attributes

  • errors (:list) - Defaults to [].

progress(assigns)

Attributes

  • min (:float) - Defaults to 0.0.
  • max (:float) - Defaults to 100.0.
  • value (:float) - Defaults to 0.0.
  • class (:string) - Defaults to "".

translate_error(arg)

Translates a form error tuple into a human-readable string.

Error tuples from changesets have the form {msg, opts} where msg may contain interpolation placeholders like %{count}.

Examples

iex> PUI.Components.translate_error({"can't be blank", []})
"can't be blank"

iex> PUI.Components.translate_error({"should be at least %{count} character(s)", [count: 3]})
"should be at least 3 character(s)"