3An implementation of [JSON Schema](http://json-schema.org/) Draft 4 in haskell.
7Still in development. Lacks solid code to handle changing resolution scope.
12{-# LANGUAGE OverloadedStrings #-}
17import qualified Data.HashMap.Strict as H
18import qualified Data.JsonSchema as JS
19import qualified Data.Vector as V
23 eitherGraph <- JS.fetchRefs JS.draft4 rawSchema H.empty
27 case JS.compileDraft4 graph rawSchema of
29 Right schema -> print $ JS.validate schema invalidData
31rawSchema :: JS.RawSchema
32rawSchema = JS.RawSchema
34 , JS._rsObject = H.singleton "uniqueItems" (Bool True) -- Schema JSON goes here.
38invalidData = Array (V.fromList ["foo", "foo"])
43fromList ["Val error against uniqueItems True for: Array (fromList [String \"foo\",String \"foo\"])"]
49 git submodule update --init
53+ This uses the [regexpr](https://hackage.haskell.org/package/regexpr-0.5.4) regular expression library for the "pattern" validator. I have no idea if this is compatible with the ECMA 262 regex dialect, which the [spec](http://json-schema.org/latest/json-schema-validation.html#anchor33) requires.
55+ `draft4.json` is from commit # cc8ec81ce0abe2385ebd6c2a6f2d6deb646f874a [here](https://github.com/json-schema/json-schema).
59Thanks to [Julian Berman](https://github.com/Julian) for the fantastic test suite.
61Also thanks to Tim Baumann for his [aeson-schema](https://hackage.haskell.org/package/aeson-schema) library. Hjsonschema's test code and its implementation of `Graph` both come from Aeson-Schema.
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list