Protocol and preliminaries for Schema 'specs', which are a common language
for schemas to use to express their structure.




Specs are a common language for Schemas to express their structure.
These two use-cases aren't priveledged, just the two that are considered core
to being a Spec.



(checker this params)
Create a function that takes [data], and either returns a walked version of data
(by default, usually just data), or a utils/ErrorContainer containing value that looks
like the 'bad' parts of data with ValidationErrors at the leaves describing the failures.

params are: subschema-checker, return-walked?, and cache.

params is a map specifying:
 - subschema-checker - a function for checking subschemas
 - returned-walked? - a boolean specifying whether to return a walked version of the data
   (otherwise, nil is returned which increases performance)
 - cache - a map structure from schema to checker, which speeds up checker creation
   when the same subschema appears multiple times, and also facilitates handling
   recursive schemas.


(subschemas this)
List all subschemas


(precondition s p err-f)
Helper for making preconditions.
Takes a schema, predicate p, and error function err-f.
If the datum passes the predicate, returns nil.
Otherwise, returns a validation error with description (err-f datum-description),
where datum-description is a (short) printable standin for the datum.


(run-checker f return-walked? s)
A helper to start a checking run, by setting the appropriate params.
For examples, see schema.core/checker or schema.coerce/coercer.



(simple-precondition s f-sym)
A simple precondition where f-sym names a predicate (e.g. (simple-precondition s map?))


(sub-checker {:keys [schema error-wrap]} {:keys [subschema-checker cache], :as params})
Should be called recursively on each subschema in the 'checker' method of a spec.
Handles caching and error wrapping behavior.


(with-cache cache cache-key wrap-recursive-delay result-fn)