metosin/scjsv


Simple JSON-Schema validator for Clojure

License: EPL-2.0

Language: Clojure


scjsv License Build Status Dependencies Status

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

Latest version

Clojars Project

Usage

  • API docs
  • validator creates a Clojure data structure validator against the given JSON Schema.
  • json-validator created a JSON string validator against the given JSON Schema.
  • JSON Schemas can be represented either as JSON strings or as Clojure Maps.
(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-2016 Metosin Oy

Distributed under the Eclipse Public License, the same as Clojure.

Project Statistics

Sourcerank 7
Repository Size 71.3 KB
Stars 33
Forks 4
Watchers 12
Open issues 0
Dependencies 2
Contributors 4
Tags 4
Created
Last updated
Last pushed

Top Contributors See all

Tommi Reiman Miikka Koskinen lvh Andreas Gebhardt

Packages Referencing this Repo

metosin/scjsv
Simple JSON-Schema validator for Clojure
Latest release 0.4.1 - Updated - 33 stars

Recent Tags See all

0.4.1 February 15, 2018
0.4.0 October 04, 2016
0.3.0 August 07, 2016
0.1.0 April 06, 2015

Something wrong with this page? Make a suggestion

Last synced: 2018-01-16 17:43:31 UTC

Login to resync this repository