Skip to content

Instantly share code, notes, and snippets.

@stijnmoreels
Created February 22, 2024 09:10
Show Gist options
  • Save stijnmoreels/b1373fd68a00ba50556ae208f4b0b062 to your computer and use it in GitHub Desktop.
Save stijnmoreels/b1373fd68a00ba50556ae208f4b0b062 to your computer and use it in GitHub Desktop.
open FPrimitive
type Guest =
private { Name : string } with
static member create name = result {
let! name = specModel id name {
notNullOrWhiteSpace "guest name should not be blank"
alphabetical "guest name should only contain alphabetical characters" }
return { Name = name } }
type GuestList =
private GuestList of Guest list with
static member none = GuestList []
static member create guests = specModel GuestList guests {
unique (fun g -> g.Name) "guest list requires unique guest names" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment