JSON schema validator
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


json-schema validator

Currently contains a usable JSON schema validator using cheshire to parse JSON. Supportes linked schemas with $ref and allows user to specify how linked URIs are loaded.

Clojars Project

Build Status


The project is tested against JSON-Schema-Test-Suite and passes most of the tests.

The macro version has problems with recursive and huge schemas. A schema that later links to itself with a "#" pointer causes an ever expanding macro expansion to take place and fails. That case requires a rethink of the macro version. The macro may also fail when the generated function would exceed the JVM limit on allowed code in a single method (64k).

Currently there are 47 tests with 658 assertions. See suite_test.clj for a the list of tests in the JSON schema test suite that are skipped.


The function version (runtime loading of schema):

(ns my.app
  (:require [webjure.json-schema.validator :refer [validate]]
            [cheshire.core :as cheshire]))

;;; then in some function
(validate (cheshire/parse-string json-schema)
          (cheshire/parse-string json-data))

Macro version loads and parses the schema and generates the validation function at compile time. The returned errors are exactly the same as in the runtime version.

(ns my.app
  (:require [webjure.json-schema.validator.macro :refer [make-validator]]
            [cheshire.core :as cheshire]))

(def my-schema-validator
     (make-validator (cheshire/parse-string json-schema) {}))

;; Then in some function
(my-schema-validator (cheshire/parse-string json-data))