Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. open FPrimitive
  2.  
  3. /// Composible specifications for your domain types:
  4. type NonEmptyString =
  5. private NonEmptyString of string with
  6. static member create x =
  7. Spec.def<string>
  8. |> Spec.notNull "should not be null"
  9. |> Spec.notEmpty "should not be empty"
  10. |> Spec.createModel NonEmptyString x
  11.  
  12. /// ...also available as computation expression.
  13. type NonEmptyList<'a> =
  14. private NonEmptyList of 'a list with
  15. static member create xs =
  16. specModel NonEmptyList xs {
  17. nonEmpty "list should not be empty"
  18. lengthBetween 1 10 "list length should be between 1-10" }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement