hecrj / composable-form / Form.Error

This module contains a form Error type.

Note: You should not need to care about this unless you are writing custom view code.


type Error
    = RequiredFieldIsEmpty
    | ValidationFailed String
    | External String

Represents a form error.

It can either be:

These type of errors are returned alongside each field in the Form.fill and Form.Base.fill functions.

You can easily write a simple function that turns this type into a String:

errorToString : Error -> String
errorToString error =
    case error of
        Error.RequiredFieldIsEmpty ->
            "this field is required"

        Error.ValidationFailed errorDescription ->
            errorDescription