Created
September 24, 2017 08:48
-
-
Save CoditCompany/dabd1604bd6839aa818f69e23fd392c8 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 (|NotMatch|_|) pattern s = | |
| if Regex.IsMatch (s, pattern) then None | |
| else Some NotMatch | |
| type Cap2 = private Cap2 of string | |
| let cap2 = function | |
| | NotMatch "^[A-Z]{2}$" -> None | |
| | s -> Some <| Cap2 s | |
| type StringAZ = private StringAZ of string | |
| let stringAZ = function | |
| | NotMatch "^[A-Za-z ]+$" -> None | |
| | s -> Some <| StringAZ s | |
| type StringAZ123 = private StringAZ123 of string | |
| let stringAZ123 = function | |
| | NotMatch "^[A-Za-z0-9 ]+$" -> None | |
| | s -> Some <| StringAZ123 s | |
| type PostInt5 = private PostalCode of int | |
| let posint5 = function | |
| | i when string i |> String.length <> 5 || i <= 0 -> None | |
| | i -> Some <| PostalCode i | |
| type Customer = | |
| { Country : Cap2 | |
| FullName : StringAZ | |
| Street : StringAZ123 | |
| City : StringAZ | |
| State : Cap2 | |
| PostalCode : PostInt5 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment