module JSONSchema.Types where
import Import
import JSONSchema.Validator.Types (Validator(..))
newtype Spec schema err
= Spec { _unSpec :: [Validator schema schema err] }
embedded :: Spec schema a -> schema -> ([schema], [schema])
embedded spec schema =
let embeds = (\val -> _embedded val schema) <$> _unSpec spec
in foldl' (\(a,b) (x,y) -> (x <> a, y <> b)) (mempty, mempty) embeds
validate
:: Spec schema err
-> schema
-> Value
-> [err]
validate spec schema v =
(\val -> _validate val schema v) =<< _unSpec spec
newtype Schema
= Schema { _unSchema :: HashMap Text Value }
deriving (Eq, Show, FromJSON, ToJSON)