hjsonschema-0.7.0.0: JSON Schema library

Safe HaskellNone
LanguageHaskell2010

Data.JsonSchema.Helpers

Contents

Synopsis

Embedded schemas finders

Modify Validators for use in Specs

giveName :: forall err. err -> ValidatorConstructor err [FailureInfo] -> ValidatorConstructor err [ValidationFailure err] Source

TODO: Is there something easier to replace these fmaps with?

modifyName :: forall valErr schemaErr. (valErr -> schemaErr) -> ValidatorConstructor schemaErr [ValidationFailure valErr] -> ValidatorConstructor schemaErr [ValidationFailure schemaErr] Source

neverBuild :: ValidatorConstructor err [ValidationFailure err] Source

It's important to know if an object's a validator (even if it will never run, like the definitions validator) because parts of it might be referenced by other validators. If one of those referenced parts is itself a valid reference we need to have fetched the correct value for it. So validators that won't run are different than non-validator objects, because even if a non-validator object has a $ref" keyword it's not a valid reference and shouldn't be fetched.

Utils

defaultFetch :: Text -> IO (Either Text ByteString) Source

Export the fetch function used by fetchReferencedSchemas

runMaybeVal :: Maybe (Value -> [a]) -> Value -> [a] Source

runMaybeVal' :: Maybe (Value -> ([a], Value)) -> Value -> ([a], Value) Source

greaterThanZero :: (Num a, Ord a) => a -> Maybe () Source

tshow :: Show a => a -> Text Source

allUniqueValues :: Vector Value -> Bool Source

This needs benchmarking, but it can't be as bad as using O(n^2) nub. (We can't use our allUnique function directly on Values because they're not an instance of Ord).

newtype OrdValue Source

Constructors

OrdValue Value