hjsonschema-1.6.1: JSON Schema library

Safe HaskellNone
LanguageHaskell2010

JSONSchema.Draft4

Contents

Synopsis

Draft 4 Schema

data SchemaWithURI schema Source #

A top-level schema along with its location.

Constructors

SchemaWithURI 

Fields

  • _swSchema :: !schema
     
  • _swURI :: !(Maybe Text)

    This is the URI from which the document was originally fetched. It's different than the schema's "id" field, which controls scope when resolving references contained in the schema.

Instances

Eq schema => Eq (SchemaWithURI schema) Source # 

Methods

(==) :: SchemaWithURI schema -> SchemaWithURI schema -> Bool #

(/=) :: SchemaWithURI schema -> SchemaWithURI schema -> Bool #

Show schema => Show (SchemaWithURI schema) Source # 

Methods

showsPrec :: Int -> SchemaWithURI schema -> ShowS #

show :: SchemaWithURI schema -> String #

showList :: [SchemaWithURI schema] -> ShowS #

data Schema Source #

Constructors

Schema 

Fields

One-step validation (getting references over HTTP)

fetchHTTPAndValidate :: SchemaWithURI Schema -> Value -> IO (Either HTTPValidationFailure ()) Source #

Fetch recursively referenced schemas over HTTP, check that both the original and referenced schemas are valid, then validate then data.

newtype SchemaInvalid Source #

A description of why a schema (or one of its reference) is itself invalid.

Nothing indicates the starting schema. Just indicates a referenced schema. The contents of the Just is the schema's URI.

NOTE: 'HashMap (Maybe Text) Invalid' would be a nicer way of defining this, but then we lose the guarantee that there's at least one key.

One-step validation (getting references from the filesystem)

fetchFilesystemAndValidate :: SchemaWithURI Schema -> Value -> IO (Either FilesystemValidationFailure ()) Source #

Fetch recursively referenced schemas from the filesystem, check that both the original and referenced schemas are valid, then validate the data.

Validation failure

data Invalid Source #

Used to report an entire instance being invalidated, as opposed to the failure of a single validator.

Fetching tools

newtype URISchemaMap schema Source #

Keys are URIs (without URI fragments).

Constructors

URISchemaMap 

Fields

Instances

Eq schema => Eq (URISchemaMap schema) Source # 

Methods

(==) :: URISchemaMap schema -> URISchemaMap schema -> Bool #

(/=) :: URISchemaMap schema -> URISchemaMap schema -> Bool #

Show schema => Show (URISchemaMap schema) Source # 

Methods

showsPrec :: Int -> URISchemaMap schema -> ShowS #

show :: URISchemaMap schema -> String #

showList :: [URISchemaMap schema] -> ShowS #

Monoid (URISchemaMap schema) Source # 

Methods

mempty :: URISchemaMap schema #

mappend :: URISchemaMap schema -> URISchemaMap schema -> URISchemaMap schema #

mconcat :: [URISchemaMap schema] -> URISchemaMap schema #

referencesViaHTTP :: SchemaWithURI Schema -> IO (Either HTTPFailure (URISchemaMap Schema)) Source #

Fetch the schemas recursively referenced by a starting schema over HTTP.

referencesViaFilesystem :: SchemaWithURI Schema -> IO (Either FilesystemFailure (URISchemaMap Schema)) Source #

Fetch the schemas recursively referenced by a starting schema from the filesystem.

Other Draft 4 things exported just in case

schemaValidity :: Schema -> [ValidatorFailure] Source #

Check that a schema itself is valid (if so the returned list will be empty).

referencesValidity Source #

Arguments

:: URISchemaMap Schema 
-> [(Text, NonEmpty ValidatorFailure)]

The first item of the tuple is the URI of a schema, the second is that schema's validation errors.

Check that a set of referenced schemas are valid (if so the returned list will be empty).

checkSchema :: URISchemaMap Schema -> SchemaWithURI Schema -> Either SchemaInvalid (Value -> [ValidatorFailure]) Source #

Checks if a schema and a set of referenced schemas are valid.

Return a function to validate data.

draft4FetchInfo :: FetchInfo Schema Source #

An instance of FetchInfo specialized for JSON Schema Draft 4.