ensolabs/designsystemet-elm/1.0.0

Designsystemet.ValidationMessage

A message about what the user typed: usually an error, sometimes a warning or a confirmation.

Mirrors ValidationMessage from @digdir/designsystemet-react.

ValidationMessage.view [] [ Html.text "Skriv inn et gyldig fødselsnummer" ]


ValidationMessage.view [ ValidationMessage.severity Color.Success ]
    [ Html.text "Brukernavnet er ledig" ]

A message is an error unless you give it another severity.

Inside a Field, <ds-field> links the message to the input with aria-describedby, and an error also makes the input aria-invalid="true". Messages of other severities are linked but don't make the input invalid. As a direct child of a Fieldset, the message is linked to every field in the group.

The composites (Textfield, Checkbox, …) render this from withError.

React → Elm

  • <ValidationMessage> → ValidationMessage.view []
  • data-color="warning" → ValidationMessage.severity Color.Warning
  • asChild + <div> → ValidationMessage.viewAs Html.div []
view : List (Attribute msg) -> List (Html msg) -> Html msg

A <p class="ds-validation-message" data-field="validation">.

(List (Attribute msg) -> List (Html msg) -> Html msg)
-> List (Attribute msg)
-> List (Html msg)
-> Html msg

The message on another element (React's asChild).

severity : Severity -> Attribute msg

How serious the message is. Defaults to Danger. The CSS has an icon and a color for each of the four.