A Field
is a simple data type that helps capture and validate form data better.
The left side of a field represents a function that takes in a value of arbitrary type,
validates it and returns a ValidationResult
.
The ValidationResult
can contain the value of the field if the validation Passed
, or
an error if the validation Failed
Type that helps capture and validate form data better
value : Field e v -> v
Extract the value out of a Field
update : Field e v -> v -> Field e v
Update the value of a Field
validate : Field e v -> ValidationResult e v
Validate a Field and get a ValidationResult
validateAll : List (Field e v) -> List (ValidationResult e v)
Validate a List of Fields and get a List of ValidationResult
isValid : Field e v -> Basics.Bool
Check if a Field is valid
isAllValid : List (Field e v) -> Basics.Bool
Check if all Fields in the list are valid
addValidation : (v -> ValidationResult e v) -> Field e v -> Field e v
Add Additional validations to a Field
map : (v -> v) -> Field e v -> Field e v
Map over the right side or the value of a Field