Skip to content

Instantly share code, notes, and snippets.

@rexcfnghk
Created May 6, 2018 13:15
Show Gist options
  • Save rexcfnghk/4806d32ca03332f466a1fe6ece6b21a9 to your computer and use it in GitHub Desktop.
Save rexcfnghk/4806d32ca03332f466a1fe6ece6b21a9 to your computer and use it in GitHub Desktop.
let makeConfig (url: string) (name: string) (age: int) =
let nameResult = validateName name
let urlResult = validateUrl url
let ageResult = validateAge age
match nameResult, urlResult, ageResult with
| Ok name, Ok url, Ok age -> Ok { Name = name; Url = url; Age = age }
| Error e1, Error e2, Error e3 -> Error (e1 @ e2 @ e3)
| Error e1, Error e2, _ -> Error (e1 @ e2)
| Error e1, _, Error e2 -> Error (e1 @ e2)
| _, Error e1, Error e2 -> Error (e1 @ e2)
| Error e, _ , _ -> Error e
| _, Error e, _ -> Error e
| _, _, Error e -> Error e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment