Skip to content

aivi.validation ​

Pure helpers for Validation E A. Use Validation when several independent checks should report their errors together. The &|> applicative pipe performs that accumulation; dependent checks use !|> and stop after a failure.

Accumulating two failures currently has an execution limitation.

aivi
use aivi.validation (
    Errors
    isValid
    isInvalid
    getOrElse
    mapErr
    toResult
    fromResult
    toOption
    map
    andThen
    fold
)

Errors E is an alias for NonEmptyList E, the standard non-empty error carrier.

FunctionTypeBehavior
isValidValidation E A -> BoolTest for Valid
isInvalidValidation E A -> BoolTest for Invalid
getOrElseA -> Validation E A -> AExtract a valid value or use a fallback
mapErr(E1 -> E2) -> Validation E1 A -> Validation E2 ATransform the error
toResultValidation E A -> Result E AConvert Valid/Invalid to Ok/Err
fromResultResult E A -> Validation E AConvert Ok/Err to Valid/Invalid
toOptionValidation E A -> Option AKeep only a valid value
map(A -> B) -> Validation E A -> Validation E BTransform a valid value
andThen(A -> Validation E B) -> Validation E A -> Validation E BRun a dependent validation
fold(E -> B) -> (A -> B) -> Validation E A -> BHandle both constructors
aivi
use aivi.validation (
    getOrElse
    map
)

type Int -> Int
func increment = . + 1

value checked : Validation Text Int = Valid 2
value next : Validation Text Int = map increment checked
value displayed : Int = getOrElse 0 next

See Pipelines & Operators for the &|> and !|> validation rules.

Error-list alias ​

Errors E is an alias for NonEmptyList E, ensuring an invalid validation carries at least one error.

(c) 2026 by Andreas Herd