orElse Functions
Namespace: FsToolkit.ErrorHandling
orElse
orElse returns the original AsyncValidation if it is Ok, otherwise returns the provided alternative AsyncValidation.
Function Signature
AsyncValidation<'ok, 'errorOutput> -> AsyncValidation<'ok, 'errorInput> -> AsyncValidation<'ok, 'errorOutput>Examples
Example 1
let result =
AsyncValidation.ok "First"
|> AsyncValidation.orElse (AsyncValidation.ok "Second")
// async { Ok "First" }Example 2
let result =
AsyncValidation.error "First"
|> AsyncValidation.orElse (AsyncValidation.ok "Second")
// async { Ok "Second" }Example 3
orElseWith
orElseWith returns the original AsyncValidation if it is Ok, otherwise calls the given function with the error list and returns its result.
Function Signature
Examples
Example 1
Example 2
Example 3
Last updated