Validating Entities

Once we have our domain model, we need a way to validate whether our data conforms to it. Clojure’s dynamic types give us great power and flexibility but also enforce fewer constraints by default. Data validation is an area in which Clojure gives us choices about when, where, and how much validation we want to provide. In areas where data is created by our code, we may want to do little or no validation, whereas we may need significant validation when accepting data from external sources.

A number of external libraries exist to provide data description and validation support. We’ll focus on Prismatic’s Schema[8] library, but you may also want to look at core.typed,[9] clj-schema,[10] Strucjure,[11] or seqex.[12]

The Prismatic ...

Get Clojure Applied now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.