mapErrors
Function Signature
('errorInput list -> 'errorOutput list) -> Validation<'ok, 'errorInput>
-> Validation<'ok, 'errorOutput>Examples
// string -> int
let getErrorCode (messages: string list) =
match messages |> List.tryFind ((=) "bad things happened") with
| Some _ -> [1]
| _ -> [0]Example 1
let result =
Validation.ok "all good" // Validation<string, string>
|> Validation.mapErrors getErrorCode // Validation<string, int>
// Ok "all good"Example 2
Last updated