hjsonschema-1.1.0.0: JSON Schema library

Safe HaskellNone
LanguageHaskell2010

Data.Validator.Draft4

Contents

Description

Turn the validation functions into actual Validators.

From this point on they know how to parse themselves from JSON and also know how to extract subschemas embedded within themselves.

Synopsis

Documentation

run :: FromJSON b => (a -> b -> [c]) -> Maybe a -> Value -> [c] Source #

For internal use.

noEmbedded :: a -> ([b], [b]) Source #

For internal use.

Numbers

Strings

Arrays

data ItemsContext schema Source #

Constructors

ItemsContext (Maybe (AdditionalItems schema)) (Items schema) 

Instances

Eq schema => Eq (ItemsContext schema) Source # 

Methods

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

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

Show schema => Show (ItemsContext schema) Source # 

Methods

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

show :: ItemsContext schema -> String #

showList :: [ItemsContext schema] -> ShowS #

FromJSON schema => FromJSON (ItemsContext schema) Source # 

Methods

parseJSON :: Value -> Parser (ItemsContext schema) #

items :: (schema -> Value -> [Fail err]) -> Validator schema (Maybe (ItemsContext schema)) (ItemsInvalid err) Source #

additionalItemsEmbedded :: Validator schema (Maybe (AdditionalItemsContext schema)) err Source #

Since items will always take care of validating additionalItems as well, the actual validation side of additionalItemsEmbedded is disabled.

newtype Definitions schema Source #

Constructors

Definitions 

Fields

Instances

Eq schema => Eq (Definitions schema) Source # 

Methods

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

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

Show schema => Show (Definitions schema) Source # 

Methods

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

show :: Definitions schema -> String #

showList :: [Definitions schema] -> ShowS #

FromJSON schema => FromJSON (Definitions schema) Source # 

Methods

parseJSON :: Value -> Parser (Definitions schema) #

definitionsEmbedded :: Validator schema (Maybe (Definitions schema)) err Source #

Placing this here since it's similar to "additionalItems". in that its validator doesn't run.

TODO: Add tests to the language agnostic test suite for both "additionalItems" and this.

Objects

newtype DependenciesContext schema Source #

Instances

dependencies :: (schema -> Value -> [Fail err]) -> Validator schema (Maybe (DependenciesContext schema)) (DependencyInvalid err) Source #

data PropertiesContext schema Source #

Constructors

PropertiesContext (Maybe (HashMap Text schema)) (Maybe (AdditionalProperties schema)) (HashMap Text schema) 

Instances

Eq schema => Eq (PropertiesContext schema) Source # 

Methods

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

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

Show schema => Show (PropertiesContext schema) Source # 
FromJSON schema => FromJSON (PropertiesContext schema) Source # 

Methods

parseJSON :: Value -> Parser (PropertiesContext schema) #

properties :: (schema -> Value -> [Fail err]) -> Validator schema (Maybe (PropertiesContext schema)) (PropertiesInvalid err) Source #

data PatternPropertiesContext schema Source #

The first argument is whether the validator should be run. If "properties" exists it will be parsed to False.

data AdditionalPropertiesContext schema Source #

The first argument is whether the validator should be run. If "properties" or "patternProperties" exist it will be parsed to False.

Any

newtype Ref Source #

Constructors

Ref 

Fields

Instances

Eq Ref Source # 

Methods

(==) :: Ref -> Ref -> Bool #

(/=) :: Ref -> Ref -> Bool #

Show Ref Source # 

Methods

showsPrec :: Int -> Ref -> ShowS #

show :: Ref -> String #

showList :: [Ref] -> ShowS #

FromJSON Ref Source # 

Methods

parseJSON :: Value -> Parser Ref #

ref :: (FromJSON schema, ToJSON schema) => VisitedSchemas -> Maybe Text -> (Maybe Text -> Maybe schema) -> (VisitedSchemas -> Maybe Text -> schema -> Value -> [Fail err]) -> Validator a (Maybe Ref) (RefInvalid err) Source #

newtype AllOf schema Source #

Constructors

AllOf 

Fields

Instances

Eq schema => Eq (AllOf schema) Source # 

Methods

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

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

Show schema => Show (AllOf schema) Source # 

Methods

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

show :: AllOf schema -> String #

showList :: [AllOf schema] -> ShowS #

FromJSON schema => FromJSON (AllOf schema) Source # 

Methods

parseJSON :: Value -> Parser (AllOf schema) #

allOf :: (schema -> Value -> [Fail err]) -> Validator schema (Maybe (AllOf schema)) err Source #

newtype AnyOf schema Source #

Constructors

AnyOf 

Fields

Instances

Eq schema => Eq (AnyOf schema) Source # 

Methods

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

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

Show schema => Show (AnyOf schema) Source # 

Methods

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

show :: AnyOf schema -> String #

showList :: [AnyOf schema] -> ShowS #

FromJSON schema => FromJSON (AnyOf schema) Source # 

Methods

parseJSON :: Value -> Parser (AnyOf schema) #

anyOf :: ToJSON schema => (schema -> Value -> [Fail err]) -> Validator schema (Maybe (AnyOf schema)) () Source #

newtype OneOf schema Source #

Constructors

OneOf 

Fields

Instances

Eq schema => Eq (OneOf schema) Source # 

Methods

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

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

Show schema => Show (OneOf schema) Source # 

Methods

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

show :: OneOf schema -> String #

showList :: [OneOf schema] -> ShowS #

FromJSON schema => FromJSON (OneOf schema) Source # 

Methods

parseJSON :: Value -> Parser (OneOf schema) #

oneOf :: ToJSON schema => (schema -> Value -> [Fail err]) -> Validator schema (Maybe (OneOf schema)) () Source #

newtype NotVal schema Source #

Constructors

NotVal 

Fields

Instances

Eq schema => Eq (NotVal schema) Source # 

Methods

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

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

Show schema => Show (NotVal schema) Source # 

Methods

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

show :: NotVal schema -> String #

showList :: [NotVal schema] -> ShowS #

FromJSON schema => FromJSON (NotVal schema) Source # 

Methods

parseJSON :: Value -> Parser (NotVal schema) #

notVal :: ToJSON schema => (schema -> Value -> [Fail err]) -> Validator schema (Maybe (NotVal schema)) () Source #