Liking cljdoc? Tell your friends :D

json-schema.core


prepare-schemaclj

source

prepare-schema*clj

(prepare-schema* input)
(prepare-schema* input params)

Prepares JSON Schema based on input string or map. An optional parameter map can be supplied to refer to relative file schemas via classpath in $ref fields.

Setting :format-validators to map of format name and validation function adds them as custom format validators. Validator takes value and returns validation error message or nil if success (prepare-schema* input { :format-validators {"uuid" (fn [value] (when-not (uuid? (parse-uuid value)) (format "[%s] is not a valid UUID value" value)))}})

Setting :classpath-aware? to true enables absolute classpath resolution. (prepare-schema* input {:classpath-aware? true})

Setting :default-resolution-scope enables relative classpath resolution. Make sure to not use HTTP URIs in schema $id fields, as this will cause it to resort to default $ref resolution via HTTP. (prepare-schema* input {:classpath-aware? true :default-resolution-scope "classpath://schemas/"})

Prepares JSON Schema based on input string or map. An optional parameter map
can be supplied to refer to relative file schemas via classpath in $ref fields.

Setting :format-validators to map of format name and validation function adds
them as custom format validators.
Validator takes value and returns validation error message or nil if success
(prepare-schema* input {
  :format-validators {"uuid" (fn [value]
                                 (when-not (uuid? (parse-uuid value))
                                   (format "[%s] is not a valid UUID value" value)))}})

Setting :classpath-aware? to true enables absolute classpath resolution.
(prepare-schema* input {:classpath-aware? true})

Setting :default-resolution-scope enables relative classpath resolution.
Make sure to not use HTTP URIs in schema $id fields, as this
will cause it to resort to default $ref resolution via HTTP.
(prepare-schema* input {:classpath-aware? true
                        :default-resolution-scope "classpath://schemas/"})
sourceraw docstring

validatecljmultimethod

Validate JSON according to JSON Schema.

If validation passes without errors, returns json. Throws ex-info with data on all errors.

Supports draft-04 -> draft-07.

To switch draft versions, simply use the according version notation in the $schema uri: http://json-schema.org/draft-04/schema http://json-schema.org/draft-06/schema http://json-schema.org/draft-07/schema

JSON and JSON Schema params has to be input as either a JSON encoded string or EDN (map for both or vector for JSON).

You can pass optional parameter :include-original-exception, in case you want the underlying exception to bubble up.

Validate JSON according to JSON Schema.

If validation passes without errors, returns json.
Throws ex-info with data on all errors.

Supports draft-04 -> draft-07.

To switch draft versions, simply use the according version notation
in the $schema uri:
http://json-schema.org/draft-04/schema
http://json-schema.org/draft-06/schema
http://json-schema.org/draft-07/schema

JSON and JSON Schema params has to be input as either a
JSON encoded string or EDN (map for both or vector for JSON).

You can pass optional parameter :include-original-exception, in
case you want the underlying exception to bubble up.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close