bkuhlmann / form-validator / FormValidator.Models

The Form Validator component models.


type alias Form key =
List (Field key)

The form model which stores a list of fields for input and validation.


type alias Field key =
{ key : key
, value : String
, validators : Validators
, errors : Errors 
}

The form field, identified by unique key, which stores a value, validators of that value, and validation errors (if any).


type alias Validators =
List Validator

A list of validators for a field.


type alias Validator =
String -> Maybe String

A field validator which evaluates to an error string (invalid) or nothing at all (valid).


type alias Values =
List Value

A list of field values to be validated.


type alias Value =
String

A field value to be validated.


type alias Errors =
List Error

The corresponding error messages of an invalid field value(s).


type alias Error =
Maybe String

The corresponding error message of an invalid field value.