bigbinary/elm-form-field/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

Field.ValidationResult

Definition

= Passed v
| Failed e

A ValidationResult describes the state of a Field once it has been validated. It can contain the value of the field if the validation Passed or an error if the validation Failed

Mapping

map : (a -> b) -> ValidationResult x a -> ValidationResult x b

Apply a function to a ValidationResult. If the ValidationResult is Passed, it will be converted. if the ValidationResult has Failed then the failure will propogate

contraMap : (a -> b) -> ValidationResult a x -> ValidationResult b x

Apply a function to a ValidationResult. If the ValidationResult is Failed, it will be converted. if the ValidationResult has Passed then the passed state will propogate

Chaining

(v -> ValidationResult e v)
-> ValidationResult e v
-> ValidationResult e v

Chain multiple validation functions

Helpers

filterFailures : List (ValidationResult e v) -> List (ValidationResult e v)

Get all ValidationResults that Failed

filterPassed : List (ValidationResult e v) -> List (ValidationResult e v)

Get all ValidationResults that Passed