Created
July 12, 2019 06:34
-
-
Save CoditCompany/b4f1f49c1bcbfed11145bd4d3462ee1c to your computer and use it in GitHub Desktop.
This file contains 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
open FPrimitive | |
/// Composible specifications for your domain types: | |
type NonEmptyString = | |
private NonEmptyString of string with | |
static member create x = | |
Spec.def<string> | |
|> Spec.notNull "should not be null" | |
|> Spec.notEmpty "should not be empty" | |
|> Spec.createModel NonEmptyString x | |
/// ...also available as computation expression. | |
type NonEmptyList<'a> = | |
private NonEmptyList of 'a list with | |
static member create xs = | |
specModel NonEmptyList xs { | |
nonEmpty "list should not be empty" | |
lengthBetween 1 10 "list length should be between 1-10" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment