February 2018
Intermediate to advanced
304 pages
7h 11m
English
Any time you receive a value from a user or an external source, that data may contain values that break your expectations. Instead, Clojure specs precisely describe those expectations, check whether the data is valid, and determine how it conforms to the specification. In the case where data is invalid, you may want to know what parts are invalid and why.
Predicates are the simplest kind of spec—they check whether a predicate matches a single value. Other specs compose predicates (and other specs) to create more complicated specifications. Some of the tools we’ll discuss include range specs, logical connectors like and and or, and collection specs. These specs combine to cover any data structure you need to describe.