Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
type ShortCode = private ShortCode of string
type ProductShortCode = private ProductShortCode of ShortCode
type AccountShortCode = private AccountShortCode of ShortCode
module ShortCode =
let create s =
if System.String.IsNullOrEmpty s then None
elif s.Length > 15 then None
else Some (ShortCode s)
let value (ShortCode s) =
s
module AccountShortCode =
let create s =
match ShortCode.create s with
| Some sc -> Some (AccountShortCode sc)
| None -> None
let value (AccountShortCode (ShortCode s)) = s
module ProductShortCode =
let create s =
match ShortCode.create s with
| Some sc -> Some (ProductShortCode sc)
| None -> None
let value (ProductShortCode (ShortCode s)) = s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment