Intro to Spec
✓ Published0🌍 Public
DDarMontou
Last edited Sep 13, 2016
Created on Sep 13, 2016
This example demonstrates how Clojure.spec validates and destructures user input through compositional specs. It shows the progression from simple predicates for phone numbers and email addresses to complex nested specs that combine user names with optional contact information. The code uses `s/def`, `s/cat`, `s/alt`, and `s/valid?` to define and test data shapes, while `s/explain` and `s/conform` provide debugging output. A final `add-new-user` function uses these specs for runtime argument validation, with the source data defined as Clojure vectors in a Gist.
AI-generated description