Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype SchemaName = SchemaName String
- data Schema
- showsPrecSchema :: Integer -> Schema -> [Char] -> [Char]
- data Field = Field {
- fieldSchema :: Schema
- isRequired :: Bool
- fieldSchemaL :: Applicative f => (Schema -> f Schema) -> Field -> f Field
- pattern Unit :: Schema
- pattern Union :: NonEmpty (Text, Schema) -> Schema
- _Unit :: Prism' Schema ()
- _Union :: Prism' Schema (NonEmpty (Text, Schema))
- type Trace = [Text]
- data Mismatch
- = MissingRecordField { }
- | MissingEnumChoices { }
- | OptionalRecordField { }
- | InvalidRecordField { }
- | InvalidEnumValue { }
- | InvalidRecordValue { }
- | InvalidConstructor { }
- | InvalidUnionValue { }
- | SchemaMismatch { }
- | ValueMismatch { }
- | EmptySchema
- | PrimValidatorMissing { }
- | PrimError { }
- | PrimMismatch { }
- | InvalidChoice {
- choiceNumber :: Int
- | UnusedFields (HashSet Text)
- | AllAlternativesFailed {
- mismatches :: [(Trace, Mismatch)]
- | UnexpectedAllOf
- | NoMatches
- type Validators = HashMap Text ValidatePrim
- type ValidatePrim = Value -> Maybe Text
- validate :: Validators -> Schema -> Value -> [(Trace, Mismatch)]
- isSubtypeOf :: Validators -> Schema -> Schema -> Either [(Trace, Mismatch)] (Value -> Value)
- type Path = Int
- selectPath :: Path -> [a] -> Maybe a
- tag :: Int -> Text
- decodeAlternatives :: Value -> [(Value, Path)]
- lookup :: (Eq a, Foldable f) => a -> f (a, b) -> Maybe b
- emptyValue :: Value
Documentation
newtype SchemaName Source #
Instances
Eq SchemaName Source # | |
Defined in Schemas.Untyped (==) :: SchemaName -> SchemaName -> Bool # (/=) :: SchemaName -> SchemaName -> Bool # | |
Data SchemaName Source # | |
Defined in Schemas.Untyped gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SchemaName -> c SchemaName # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SchemaName # toConstr :: SchemaName -> Constr # dataTypeOf :: SchemaName -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SchemaName) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SchemaName) # gmapT :: (forall b. Data b => b -> b) -> SchemaName -> SchemaName # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SchemaName -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SchemaName -> r # gmapQ :: (forall d. Data d => d -> u) -> SchemaName -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> SchemaName -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> SchemaName -> m SchemaName # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SchemaName -> m SchemaName # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SchemaName -> m SchemaName # | |
Show SchemaName Source # | |
Defined in Schemas.Untyped showsPrec :: Int -> SchemaName -> ShowS # show :: SchemaName -> String # showList :: [SchemaName] -> ShowS # | |
IsString SchemaName Source # | |
Defined in Schemas.Untyped fromString :: String -> SchemaName # | |
HasSchema SchemaName Source # | |
Defined in Schemas.Class |
A schema for untyped data, such as JSON or XML.
- introduction forms:
extractSchema
,schemaFor
,mempty
- operations:
isSubtypeOf
,versions
,coerce
,validate
- composition: '(<>)'
Array Schema | |
StringMap Schema | |
Enum (NonEmpty Text) | |
Record (HashMap Text Field) | |
OneOf (NonEmpty Schema) | Decoding works for all alternatives, encoding only for one |
Prim Text | Carries the name of primitive type |
Named SchemaName Schema | |
Empty | The void schema |
Instances
Field | |
|
Instances
Eq Field Source # | |
Data Field Source # | |
Defined in Schemas.Untyped gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Field -> c Field # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Field # dataTypeOf :: Field -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Field) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Field) # gmapT :: (forall b. Data b => b -> b) -> Field -> Field # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Field -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Field -> r # gmapQ :: (forall d. Data d => d -> u) -> Field -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Field -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Field -> m Field # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Field -> m Field # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Field -> m Field # | |
Show Field Source # | |
Generic Field Source # | |
HasSchema Field Source # | |
Defined in Schemas.Class | |
type Rep Field Source # | |
Defined in Schemas.Untyped type Rep Field = D1 (MetaData "Field" "Schemas.Untyped" "schemas-0.4.0.2-1entpYntvHrFoOC9cjBR1g" False) (C1 (MetaCons "Field" PrefixI True) (S1 (MetaSel (Just "fieldSchema") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Schema) :*: S1 (MetaSel (Just "isRequired") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool))) |
fieldSchemaL :: Applicative f => (Schema -> f Schema) -> Field -> f Field Source #
Instances
Eq Mismatch Source # | |
Show Mismatch Source # | |
Exception Mismatch Source # | |
Defined in Schemas.Untyped toException :: Mismatch -> SomeException # fromException :: SomeException -> Maybe Mismatch # displayException :: Mismatch -> String # | |
MonadError TracedMismatches Result Source # | |
Defined in Schemas.Internal throwError :: TracedMismatches -> Result a # catchError :: Result a -> (TracedMismatches -> Result a) -> Result a # |
type Validators = HashMap Text ValidatePrim 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
returns a witness that isSubtypeOf
supsub
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
selectPath :: Path -> [a] -> Maybe a Source #
emptyValue :: Value Source #