-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Types and type classes for defining JSON schemas.
--
@package json-schema
@version 0.7.2.0
-- | Types for defining JSON schemas.
module Data.JSON.Schema.Types
-- | Class representing JSON schemas
class JSONSchema a
schema :: JSONSchema a => Proxy a -> Schema
-- | A schema for a JSON value.
data Schema
-- | A choice of multiple values, e.g. for sum types.
Choice :: [Schema] -> Schema
-- | A JSON object.
Object :: [Field] -> Schema
-- | A JSON object with arbitrary keys.
Map :: Schema -> Schema
-- | An array. The LengthBound represent the lower and upper bound of the
-- array size. The value unboundedLength indicates no bound. The
-- boolean denotes whether items have to be unique.
Array :: LengthBound -> Bool -> Schema -> Schema
-- | A fixed-length tuple of different values.
Tuple :: [Schema] -> Schema
-- | A string. The LengthBound denote the lower and upper bound of the
-- length of the string. The value unboundedLength indicates no
-- bound.
Value :: LengthBound -> Schema
-- | A Bool.
Boolean :: Schema
-- | A number. The Bound denote the lower and upper bound on the value. The
-- value unbounded indicates no bound.
Number :: Bound -> Schema
-- | A Value that never changes. Can be combined with Choice to create
-- enumerables.
Constant :: Value -> Schema
-- | Any value is allowed.
Any :: Schema
-- | A field in an object.
data Field
Field :: Text -> Bool -> Schema -> Field
key :: Field -> Text
required :: Field -> Bool
content :: Field -> Schema
-- | A type for bounds on number domains. Use Nothing when no lower or
-- upper bound makes sense
data Bound
Bound :: Maybe Int -> Maybe Int -> Bound
lower :: Bound -> Maybe Int
upper :: Bound -> Maybe Int
-- | A type for bounds on lengths for strings and arrays. Use Nothing when
-- no lower or upper bound makes sense
data LengthBound
LengthBound :: Maybe Int -> Maybe Int -> LengthBound
lowerLength :: LengthBound -> Maybe Int
upperLength :: LengthBound -> Maybe Int
unbounded :: Bound
unboundedLength :: LengthBound
instance Eq Bound
instance Show Bound
instance Eq LengthBound
instance Show LengthBound
instance Eq Field
instance Show Field
instance Eq Schema
instance Show Schema
instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d, JSONSchema e, JSONSchema f, JSONSchema g, JSONSchema h, JSONSchema i, JSONSchema j, JSONSchema k, JSONSchema l, JSONSchema m, JSONSchema n, JSONSchema o) => JSONSchema (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d, JSONSchema e, JSONSchema f, JSONSchema g, JSONSchema h, JSONSchema i, JSONSchema j, JSONSchema k, JSONSchema l, JSONSchema m, JSONSchema n) => JSONSchema (a, b, c, d, e, f, g, h, i, j, k, l, m, n)
instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d, JSONSchema e, JSONSchema f, JSONSchema g, JSONSchema h, JSONSchema i, JSONSchema j, JSONSchema k, JSONSchema l, JSONSchema m) => JSONSchema (a, b, c, d, e, f, g, h, i, j, k, l, m)
instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d, JSONSchema e, JSONSchema f, JSONSchema g, JSONSchema h, JSONSchema i, JSONSchema j, JSONSchema k, JSONSchema l) => JSONSchema (a, b, c, d, e, f, g, h, i, j, k, l)
instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d, JSONSchema e, JSONSchema f, JSONSchema g, JSONSchema h, JSONSchema i, JSONSchema j, JSONSchema k) => JSONSchema (a, b, c, d, e, f, g, h, i, j, k)
instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d, JSONSchema e, JSONSchema f, JSONSchema g, JSONSchema h, JSONSchema i, JSONSchema j) => JSONSchema (a, b, c, d, e, f, g, h, i, j)
instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d, JSONSchema e, JSONSchema f, JSONSchema g, JSONSchema h, JSONSchema i) => JSONSchema (a, b, c, d, e, f, g, h, i)
instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d, JSONSchema e, JSONSchema f, JSONSchema g, JSONSchema h) => JSONSchema (a, b, c, d, e, f, g, h)
instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d, JSONSchema e, JSONSchema f, JSONSchema g) => JSONSchema (a, b, c, d, e, f, g)
instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d, JSONSchema e, JSONSchema f) => JSONSchema (a, b, c, d, e, f)
instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d, JSONSchema e) => JSONSchema (a, b, c, d, e)
instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d) => JSONSchema (a, b, c, d)
instance (JSONSchema a, JSONSchema b, JSONSchema c) => JSONSchema (a, b, c)
instance (JSONSchema a, JSONSchema b) => JSONSchema (a, b)
instance JSONSchema a => JSONSchema (Set a)
instance JSONSchema UTCTime
instance (IsString k, JSONSchema v) => JSONSchema (HashMap k v)
instance (IsString k, JSONSchema v) => JSONSchema (Map k v)
instance JSONSchema a => JSONSchema (Vector a)
instance JSONSchema a => JSONSchema [a]
instance JSONSchema a => JSONSchema (Maybe a)
instance JSONSchema Text
instance JSONSchema Text
instance JSONSchema Bool
instance HasResolution a => JSONSchema (Fixed a)
instance JSONSchema Double
instance JSONSchema Float
instance JSONSchema Word32
instance JSONSchema Integer
instance JSONSchema Int
instance JSONSchema ()
-- | Combinators for creating JSON schemas.
module Data.JSON.Schema.Combinators
-- | A schema combinator.
type SchemaC = Schema -> Schema
-- | Optionality operator for schemas.
(<|>) :: Schema -> Schema -> Schema
-- | Tupling.
(<+>) :: Schema -> Schema -> Schema
-- | If passed two objects, merges the fields. Otherwise creates a tuple.
merge :: Schema -> Schema -> Schema
-- | Create an object with a single field.
field :: Text -> Bool -> Schema -> Schema
-- | An unbounded string.
value :: Schema
-- | An unbounded number.
number :: Schema
-- | An unbounded array with non-unique values.
array :: Schema -> Schema
-- | Add a field to an object, or tuple if passed a non-object.
addField :: Text -> Bool -> Schema -> SchemaC
-- | Add multiple fields to an object, or tuple if passed a non-object.
addFields :: [(Text, Bool, Schema)] -> SchemaC
-- | An empty object.
empty :: Schema
-- | A choice between constant values.
enum :: [Value] -> Schema
unbounded :: Bound
unboundedLength :: LengthBound
-- | The provided schema or null.
nullable :: Schema -> Schema
-- | Generic derivation of schemas. The schemas generated match the JSON
-- generated by type 'generic-aeson' package. See that package for
-- documentation on the format and examples of it.
module Data.JSON.Schema.Generic
class GJSONSchema f
-- | Derive a JSON schema for types with an instance of Generic.
gSchema :: (Generic a, GJSONSchema (Rep a), ConNames (Rep a), GIsEnum (Rep a)) => Proxy a -> Schema
gSchemaWithSettings :: (Generic a, GJSONSchema (Rep a), ConNames (Rep a), GIsEnum (Rep a)) => Settings -> Proxy a -> Schema
instance [overlap ok] (Selector c, GJSONSchema f) => GJSONSchema (M1 S c f)
instance [overlap ok] Selector c => GJSONSchema (M1 S c (K1 i (Maybe String)))
instance [overlap ok] (Selector c, JSONSchema a) => GJSONSchema (M1 S c (K1 i (Maybe a)))
instance [overlap ok] GJSONSchema f => GJSONSchema (M1 D c f)
instance [overlap ok] (Constructor c, GJSONSchema f) => GJSONSchema (M1 C c f)
instance [overlap ok] (GJSONSchema f, GJSONSchema g) => GJSONSchema (f :*: g)
instance [overlap ok] (GJSONSchema f, GJSONSchema g) => GJSONSchema (f :+: g)
instance [overlap ok] GJSONSchema U1
instance [overlap ok] GJSONSchema (K1 i String)
instance [overlap ok] JSONSchema c => GJSONSchema (K1 i c)
module Data.JSON.Schema
-- | A concrete, poly-kinded proxy type
data Proxy (t :: k) :: k -> *
Proxy :: Proxy
module Data.JSON.Schema.Validate
-- | Predicate version of validate.
isValid :: Schema -> Value -> Bool
-- | Validates a value against a schema returning errors.
validate :: Schema -> Value -> Vector ValidationError
data ValidationError
ValidationError :: Vector Text -> ErrorType -> ValidationError
-- | The Path to the property where the error occured, empty if the error
-- is on the top level.
path :: ValidationError -> Vector Text
errorType :: ValidationError -> ErrorType
data ErrorType
-- | General type error.
Mismatch :: Schema -> Value -> ErrorType
-- | Number out of bounds.
BoundError :: Bound -> Scientific -> ErrorType
-- | String or Array out of bounds.
LengthBoundError :: LengthBound -> Int -> ErrorType
-- | Expected and actual tuple length.
TupleLength :: Int -> Int -> ErrorType
-- | A required field is missing.
MissingRequiredField :: Text -> ErrorType
-- | All choices failed, contains the error of each branch.
ChoiceError :: (Vector (Vector ValidationError)) -> Value -> ErrorType
-- | The elements in the array that are duplicated with the number of
-- occurences (at least 2).
NonUniqueArray :: (HashMap Value Int) -> ErrorType
instance Eq ErrorType
instance Show ErrorType
instance Eq ValidationError
instance Show ValidationError
instance Functor M
instance Applicative M
instance Monad M
instance MonadWriter (Vector ValidationError) M
instance MonadReader (Vector Text) M