Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data SchemaWithURI schema = SchemaWithURI {}
- data Schema = Schema {
- _schemaVersion :: Maybe Text
- _schemaId :: Maybe Text
- _schemaRef :: Maybe Text
- _schemaDefinitions :: Maybe (HashMap Text Schema)
- _schemaOther :: HashMap Text Value
- _schemaMultipleOf :: Maybe Scientific
- _schemaMaximum :: Maybe Scientific
- _schemaExclusiveMaximum :: Maybe Bool
- _schemaMinimum :: Maybe Scientific
- _schemaExclusiveMinimum :: Maybe Bool
- _schemaMaxLength :: Maybe Int
- _schemaMinLength :: Maybe Int
- _schemaPattern :: Maybe Text
- _schemaMaxItems :: Maybe Int
- _schemaMinItems :: Maybe Int
- _schemaUniqueItems :: Maybe Bool
- _schemaItems :: Maybe (Items Schema)
- _schemaAdditionalItems :: Maybe (AdditionalItems Schema)
- _schemaMaxProperties :: Maybe Int
- _schemaMinProperties :: Maybe Int
- _schemaRequired :: Maybe (Set Text)
- _schemaDependencies :: Maybe (HashMap Text (Dependency Schema))
- _schemaProperties :: Maybe (HashMap Text Schema)
- _schemaPatternProperties :: Maybe (HashMap Text Schema)
- _schemaAdditionalProperties :: Maybe (AdditionalProperties Schema)
- _schemaEnum :: Maybe (NonEmpty Value)
- _schemaType :: Maybe TypeValidator
- _schemaAllOf :: Maybe (NonEmpty Schema)
- _schemaAnyOf :: Maybe (NonEmpty Schema)
- _schemaOneOf :: Maybe (NonEmpty Schema)
- _schemaNot :: Maybe Schema
- emptySchema :: Schema
- fetchHTTPAndValidate :: SchemaWithURI Schema -> Value -> IO (Either HTTPValidationFailure ())
- data HTTPValidationFailure
- data HTTPFailure
- newtype SchemaInvalid = SchemaInvalid {}
- fetchFilesystemAndValidate :: SchemaWithURI Schema -> Value -> IO (Either FilesystemValidationFailure ())
- data FilesystemValidationFailure
- data FilesystemFailure
- data Invalid = Invalid {}
- data ValidatorFailure
- = FailureMultipleOf MultipleOfInvalid
- | FailureMaximum MaximumInvalid
- | FailureMinimum MinimumInvalid
- | FailureMaxLength MaxLengthInvalid
- | FailureMinLength MinLengthInvalid
- | FailurePattern PatternInvalid
- | FailureMaxItems MaxItemsInvalid
- | FailureMinItems MinItemsInvalid
- | FailureUniqueItems UniqueItemsInvalid
- | FailureItems (ItemsInvalid ValidatorFailure)
- | FailureAdditionalItems (AdditionalItemsInvalid ValidatorFailure)
- | FailureMaxProperties MaxPropertiesInvalid
- | FailureMinProperties MinPropertiesInvalid
- | FailureRequired RequiredInvalid
- | FailureDependencies (DependenciesInvalid ValidatorFailure)
- | FailurePropertiesRelated (PropertiesRelatedInvalid ValidatorFailure)
- | FailureRef (RefInvalid ValidatorFailure)
- | FailureEnum EnumInvalid
- | FailureType TypeValidatorInvalid
- | FailureAllOf (AllOfInvalid ValidatorFailure)
- | FailureAnyOf (AnyOfInvalid ValidatorFailure)
- | FailureOneOf (OneOfInvalid ValidatorFailure)
- | FailureNot NotValidatorInvalid
- newtype URISchemaMap schema = URISchemaMap {
- _unURISchemaMap :: HashMap Text schema
- referencesViaHTTP :: SchemaWithURI Schema -> IO (Either HTTPFailure (URISchemaMap Schema))
- referencesViaFilesystem :: SchemaWithURI Schema -> IO (Either FilesystemFailure (URISchemaMap Schema))
- metaSchema :: Schema
- metaSchemaBytes :: ByteString
- schemaValidity :: Schema -> [ValidatorFailure]
- referencesValidity :: URISchemaMap Schema -> [(Text, NonEmpty ValidatorFailure)]
- checkSchema :: URISchemaMap Schema -> SchemaWithURI Schema -> Either SchemaInvalid (Value -> [ValidatorFailure])
- draft4FetchInfo :: FetchInfo Schema
Draft 4 Schema
data SchemaWithURI schema Source #
A top-level schema along with its location.
Eq schema => Eq (SchemaWithURI schema) Source # | |
Show schema => Show (SchemaWithURI schema) Source # | |
emptySchema :: Schema Source #
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.
data HTTPValidationFailure Source #
data HTTPFailure Source #
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.
data FilesystemFailure Source #
Validation failure
Used to report an entire instance being invalidated, as opposed to the failure of a single validator.
data ValidatorFailure Source #
Fetching tools
newtype URISchemaMap schema Source #
Keys are URIs (without URI fragments).
URISchemaMap | |
|
Eq schema => Eq (URISchemaMap schema) Source # | |
Show schema => Show (URISchemaMap schema) Source # | |
Monoid (URISchemaMap schema) Source # | |
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
metaSchema :: Schema Source #
schemaValidity :: Schema -> [ValidatorFailure] Source #
Check that a schema itself is valid (if so the returned list will be empty).
:: 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.