Home

Awesome

scjsv License Build Status Dependencies Status

Simple Clojure JSON-Schema Validator - on top of java-json-tools/json-schema-validator.

scjsv supports JSON Schema up to draft-04. If you need support for draft-07, see luposlip/json-schema.

Latest version

Clojars Project

scjsv requires Java 1.8 or later.

Usage

(require '[scjsv.core :as v])

(def schema {:$schema "http://json-schema.org/draft-04/schema#"
             :type "object"
             :properties {:id {:type "integer"}}
             :required [:id]})

(def validate (v/validator schema))

(validate {:id 1})
; nil

(validate {})
; ({:domain "validation"
;   :instance {:pointer ""}
;   :keyword "required"
;   :level "error"
;   :message "object has missing required properties ([\"id\"])"
;   :missing ["id"]
;   :required ["id"]
;   :schema {:loadingURI "#" :pointer ""}})

License

Copyright © 2015-2018 Metosin Oy.

Distributed under the Eclipse Public License 2.0.