hjsonschema-0.2.0.0: Haskell implementation of JSON Schema v4.

Safe HaskellNone
LanguageHaskell2010

Data.JsonSchema.Validators

Description

This is generally meant to be an internal module. It's only exposed in case you want to make your own Spec. If you just want to use JSON Schema Draft 4 use the preassembled draft4 instead.

This module exposes three types of functions. To describe them we'll use the properties validators as an example.

  1. Functions which describe how subschemas (if any) are embedded in this validator. This is how fetchRefs is able to find "$refs" and "ids".
  2. Functions that aren't followed by apostrophes have the type ValidatorGen and are meant to be used in a Spec. Examples are properties and additionalProperties.
  3. Functions that are followed by a single apostrophe, such as additionalProperties', aren't meant to be used standalone in a Spec. Instead they're used by other validators. For instance, additionalProperties disables itself if the key "properties" is present to allow additionalProperties to handle its validation. Placing the actual meat of additionalProperties in additionalProperties' allows for code reuse between properties and additionalProperties.
  4. Functions that are followed by a double apostrophe, such as patternProperties'', return an enhanced validator. It not only reports errors, but also the parts of the target data that it matches. These functions also aren't used in a Spec instance, but are necessary helpers for actual validators in certain situations.

Synopsis

Documentation

items :: ValidatorGen Source

Also covers additionalItems.

We can leave additionalItems out of the spec HashMap, since items defaults to {}, and if it isn't present additionalItems will always validate successfully.