hjsonschema-0.10.0.3: JSON Schema library

Safe HaskellNone
LanguageHaskell2010

Data.JsonSchema.Draft4

Contents

Synopsis

Documentation

data Schema Source #

Constructors

Schema 

Fields

One-step validation

Fetching tools

data SchemaWithURI schema Source #

Constructors

SchemaWithURI 

Fields

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 ReferencedSchemas schema Source #

Constructors

ReferencedSchemas 

Fields

Instances

Eq schema => Eq (ReferencedSchemas schema) Source # 

Methods

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

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

Show schema => Show (ReferencedSchemas schema) Source # 

Failure

data Failure err Source #

Validators shouldn't know more about the schema they're going to be used with than necessary. If a validator throws errors using the error sum type of a particular schema, then it can't be used with other schemas later that have different error sum types (at least not without writing partial functions).

Thus validators that can only fail in one way return FailureInfos. Validators that can fail in multiple ways return ValidationFailures along with an custom error sum type for that particular validator.

It's the job of a schema's validate function to unify the errors produced by the validators it uses into a single error sum type for that schema. The schema's validate function will return a ValidationFailure with that sum type as its type argument.

Instances

Eq err => Eq (Failure err) Source # 

Methods

(==) :: Failure err -> Failure err -> Bool #

(/=) :: Failure err -> Failure err -> Bool #

Show err => Show (Failure err) Source # 

Methods

showsPrec :: Int -> Failure err -> ShowS #

show :: Failure err -> String #

showList :: [Failure err] -> ShowS #

data ValidatorChain Source #

Constructors

MultipleOf 
Maximum 
ExclusiveMaximum 
Minimum 
ExclusiveMinimum 
MaxLength 
MinLength 
PatternValidator 
MaxItems 
MinItems 
UniqueItems 
Items ValidatorChain 
AdditionalItemsBool 
AdditionalItemsObject ValidatorChain 
MaxProperties 
MinProperties 
Required 
SchemaDependency ValidatorChain 
PropertyDependency 
Properties ValidatorChain 
PatternProperties ValidatorChain 
AdditionalPropertiesBool 
AdditionalPropertiesObject ValidatorChain 
RefResolution

Indicates a reference that failed to resolve.

NOTE: The language agnostic test suite doesn't specify if this should cause a validation error or should allow data to pass. We choose to return a validation error.

Also note that ideally we would enforce in the type system that any failing references be dealt with before valididation. Then this could be removed entirely.

Ref ValidatorChain 
Enum 
TypeValidator 
AllOf ValidatorChain 
AnyOf 
OneOf 
NotValidator 

Other Draft 4 things exported just in case

checkSchema :: ReferencedSchemas Schema -> SchemaWithURI Schema -> Either (NonEmpty Invalid) (Value -> [Invalid]) Source #

Check the that a schema itself is valid.

Return a function to validate data.

schemaValidity :: Schema -> [Invalid] Source #

Check that a schema itself is valid.