schemas-0.1.1.0: schema guided serialization

Safe HaskellNone
LanguageHaskell2010

Schemas.Untyped

Synopsis

Documentation

data Schema Source #

A schema for untyped data, such as JSON or XML.

Constructors

Array Schema 
StringMap Schema 
Enum (NonEmpty Text) 
Record (HashMap Text Field) 
AllOf (NonEmpty Schema)

Encoding and decoding work for all alternatives

OneOf (NonEmpty Schema)

Decoding works for all alternatives, encoding only for one

Prim Text

Carries the name of primitive type

Instances
Eq Schema Source # 
Instance details

Defined in Schemas.Untyped

Methods

(==) :: Schema -> Schema -> Bool #

(/=) :: Schema -> Schema -> Bool #

Show Schema Source # 
Instance details

Defined in Schemas.Untyped

Generic Schema Source # 
Instance details

Defined in Schemas.Untyped

Associated Types

type Rep Schema :: Type -> Type #

Methods

from :: Schema -> Rep Schema x #

to :: Rep Schema x -> Schema #

Semigroup Schema Source # 
Instance details

Defined in Schemas.Untyped

Monoid Schema Source # 
Instance details

Defined in Schemas.Untyped

HasSchema Schema Source # 
Instance details

Defined in Schemas.Class

type Rep Schema Source # 
Instance details

Defined in Schemas.Untyped

data Field Source #

Constructors

Field 

Fields

Instances
Eq Field Source # 
Instance details

Defined in Schemas.Untyped

Methods

(==) :: Field -> Field -> Bool #

(/=) :: Field -> Field -> Bool #

Show Field Source # 
Instance details

Defined in Schemas.Untyped

Methods

showsPrec :: Int -> Field -> ShowS #

show :: Field -> String #

showList :: [Field] -> ShowS #

Generic Field Source # 
Instance details

Defined in Schemas.Untyped

Associated Types

type Rep Field :: Type -> Type #

Methods

from :: Field -> Rep Field x #

to :: Rep Field x -> Field #

HasSchema Field Source # 
Instance details

Defined in Schemas.Class

type Rep Field Source # 
Instance details

Defined in Schemas.Untyped

type Rep Field = D1 (MetaData "Field" "Schemas.Untyped" "schemas-0.1.1.0-9zDZuHVzzF7Fl693Gilt6H" False) (C1 (MetaCons "Field" PrefixI True) (S1 (MetaSel (Just "fieldSchema") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Schema) :*: S1 (MetaSel (Just "isRequired") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool)))

pattern Empty :: Schema Source #

finite :: Natural -> Schema -> Schema Source #

Ensure that a Schema is finite by enforcing a max depth. The result is guaranteed to be a supertype of the input.

finiteValue :: Validators -> Natural -> Schema -> Value -> Value Source #

Ensure that a Value is finite by enforcing a max depth in a schema preserving way

versions :: Schema -> NonEmpty Schema Source #

Flattens alternatives. Returns a schema without AllOf constructors

type Trace = [Text] Source #

validate :: Validators -> Schema -> Value -> [(Trace, Mismatch)] Source #

Structural validation of a JSON value against a schema Ignores extraneous fields in records

isSubtypeOf :: Validators -> Schema -> Schema -> Either [(Trace, Mismatch)] (Value -> Value) Source #

sub isSubtypeOf sup returns a witness that sub is a subtype of sup, i.e. a cast function sub -> sup

Array Bool `isSubtypeOf` Bool

Just function > Record [("a", Bool)] isSubtypeOf Record [("a", Number)] Nothing

type Path = Int Source #

selectPath :: Path -> [a] -> Maybe a Source #

lookup :: (Eq a, Foldable f) => a -> f (a, b) -> Maybe b Source #

Generalized lookup for Foldables