Header menu logo TDesu.FSharp

Validation<'TValue, 'TError> Type

Applicative validation: collects ALL errors instead of short-circuiting. Use and! in the validation { } CE to run validators in parallel and collect errors.

Example

 let validateName name =
     if String.IsNullOrWhiteSpace name then Validation.error "Name required"
     else Validation.ok name

 let validateAge age =
     if age < 0 || age > 150 then Validation.error "Invalid age"
     else Validation.ok age

 validation {
     let! name = validateName input.Name
     and! age = validateAge input.Age
     return { Name = name; Age = age }
 }
 // If both fail: Error ["Name required"; "Invalid age"]
val validateName: name: 'a -> 'b
val name: 'a
module String from Microsoft.FSharp.Core
val validateAge: age: int -> 'a
val age: int

Union cases

Union case Description

Error 'TError list

Full Usage: Error 'TError list

Parameters:
    Item : 'TError list

Item : 'TError list

Ok 'TValue

Full Usage: Ok 'TValue

Parameters:
    Item : 'TValue

Item : 'TValue

Instance members

Instance member Description

this.IsError

Full Usage: this.IsError

Returns: bool
Returns: bool

this.IsOk

Full Usage: this.IsOk

Returns: bool
Returns: bool

Type something to start searching.