Aria Haghighi - Prismatic's Schema for Server and Client-Side Data Shape Declaration and Validation





The interactive transcript could not be loaded.


Rating is available when the video has been rented.
This feature is not available right now. Please try again later.
Published on Jan 6, 2014

We introduce Schema, a Clojure and ClojureScript library for declaring and validating the shape of data. One of the difficulties with bringing Clojure into a team is the overhead of understanding the kind of data (e.g., list of strings versus, 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.

A schema is a declarative representation of the shape of data. For instance, a map from strings to sequences of doubles would be represented by the singleton map `{string [double]}`. Schemas can be validated at runtime on a function for a particular namespace and they can be composed and programmatically manipulated since they are just data. Unlike a standard type system, schemas are always optional and are a *simple* extension of Clojure's type-hinting system and often much simpler and precise than a doc string. Schema also includes optional extensions of `defn` and `defrecord` that integrate well with schema, enabling low-effort definition and validation.

The Schema library can also be used in ClojureScript, allowing our frontend and backend to share the Schema declarations behind the API input/output contract. This results in less code-duplication between client and server as well as far less mis-communication and error between teams.

Aria Haghighi is the co-founder and CTO of Prismatic, the web and mobile news service growing fast thanks to rich relevance and beautiful design. He holds a PhD in Computer Science from the University of California, Berkeley, specializing in Statistical Natural Language Processing and Machine Learning. During his graduate studies, he published over 20 papers in top conferences, was a Microsoft Research Fellow, and won multiple awards for his research and teaching. He also holds a BS in Mathematics with distinction from Stanford University.


When autoplay is enabled, a suggested video will automatically play next.

Up next

to add this to Watch Later

Add to

Loading playlists...