Created
May 6, 2018 13:15
-
-
Save rexcfnghk/4806d32ca03332f466a1fe6ece6b21a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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