3025 shaares
A Clojure(Script) library for declarative data description and validation.
One of the difficulties with bringing Clojure into a team is the overhead of understanding the kind of data (e.g., list of strings, nested map from long to string to double) that a function expects and returns. While a full-blown type system is one solution to this problem, we present a lighter weight solution: schemas. (For more details on why we built Schema, check out this post.
- Referenced post: Schema for Clojure(Script) Data Shape Declaration and Validation
Schema is a rich language for describing data shapes, with a variety of features:
- Data validation, with descriptive error messages of failures (targeted at programmers)
- Annotation of function arguments and return values, with optional runtime validation
- Schema-driven data coercion, which can automatically, succinctly, and safely convert complex data types (see the Coercion section below)
- Other
- Schema is also built into our plumbing and fnhouse libraries, which illustrate how we build services and APIs easily and safely with Schema
- Schema also supports experimental clojure.test.check data generation from Schemas, as well as completion of partial datums, features we've found very useful when writing tests as part of the
schema-generatorslibrary