Safe Haskell | None |
---|---|
Language | Haskell2010 |
- noEm :: EmbeddedSchemas
- objEmbed :: EmbeddedSchemas
- arrayEmbed :: EmbeddedSchemas
- objOrArrayEmbed :: EmbeddedSchemas
- objMembersEmbed :: EmbeddedSchemas
- giveName :: forall err. err -> ValidatorConstructor err [FailureInfo] -> ValidatorConstructor err [ValidationFailure err]
- modifyName :: forall valErr schemaErr. (valErr -> schemaErr) -> ValidatorConstructor schemaErr [ValidationFailure valErr] -> ValidatorConstructor schemaErr [ValidationFailure schemaErr]
- neverBuild :: ValidatorConstructor err [ValidationFailure err]
- defaultFetch :: Text -> IO (Either Text ByteString)
- modifyFailureName :: (a -> b) -> ValidationFailure a -> ValidationFailure b
- eitherToMaybe :: Either a b -> Maybe b
- runMaybeVal :: Maybe (Value -> [a]) -> Value -> [a]
- runMaybeVal' :: Maybe (Value -> ([a], Value)) -> Value -> ([a], Value)
- toObj :: Value -> Maybe (HashMap Text Value)
- fromJSONInt :: Value -> Maybe Int
- toTxt :: Value -> Maybe Text
- greaterThanZero :: (Num a, Ord a) => a -> Maybe ()
- tshow :: Show a => a -> Text
- allUnique :: Ord a => Vector a -> Bool
- allUniqueValues :: Vector Value -> Bool
- newtype OrdValue = OrdValue Value
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
modifyFailureName :: (a -> b) -> ValidationFailure a -> ValidationFailure b Source
eitherToMaybe :: Either a b -> Maybe b Source
runMaybeVal :: Maybe (Value -> [a]) -> Value -> [a] Source
fromJSONInt :: Value -> Maybe Int Source
greaterThanZero :: (Num a, Ord a) => a -> Maybe () 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).