No spec is an island
Composing individual specifications is an effective way to build larger abstractions in specifications without creating fixed hierarchical structures that are harder to refactor.
Require specification namespace to the page
spec/and is used when all specifications should be true.
spec/or is use when one or more specifications should be true
Each condition in the spec is annotated with a label for each conditional branches.
Labels are included in the return result from
spec/explain when values do not conform to a specification, providing context as to why a value failed the specification.
When an or is conformed, it returns a vector with the condition name and conformed value.
Before composing a more abstract specification, first define individual specifications
Composing hash-map specificationλ︎
The individual specifications can now be composed into a single specification.
keys function combines specifications to form a composite specification in the form of a Clojure hash-map.
Use the composite specification with a value