bigbinary / elm-form-field / Field.ValidationResult

Definition


type ValidationResult e v
    = 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

andThen : (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