swagger2-2.0.2: Swagger 2.0 data model

Copyright(c) 2015 GetShopTV
LicenseBSD3
MaintainerNickolay Kudasov <nickolay@getshoptv.com>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Data.Swagger.Internal.Schema.Validation

Description

Validate JSON values with Swagger Schema.

Synopsis

Documentation

validateToJSON :: forall a. (ToJSON a, ToSchema a) => a -> [ValidationError] Source

Validate ToJSON instance matches ToSchema for a given value. This can be used with QuickCheck to ensure those instances are coherent:

validateToJSON (x :: Int) == []

NOTE: validateToJSON does not perform string pattern validation. See validateToJSONWithPatternChecker.

validateToJSONWithPatternChecker :: forall a. (ToJSON a, ToSchema a) => (Pattern -> Text -> Bool) -> a -> [ValidationError] Source

Validate ToJSON instance matches ToSchema for a given value and pattern checker. This can be used with QuickCheck to ensure those instances are coherent.

For validation without patterns see validateToJSON.

type ValidationError = String Source

Validation error message.

data Result a Source

Validation result type.

Constructors

Failed [ValidationError]

Validation failed with a list of error messages.

Passed a

Validation passed.

data Config Source

Validation configuration.

Constructors

Config 

Fields

configPatternChecker :: Pattern -> Text -> Bool

Pattern checker for _paramSchemaPattern validation.

configDefinitions :: Definitions Schema

Schema definitions in scope to resolve references.

defaultConfig :: Config Source

Default Config:

defaultConfig = Config
  { configPatternChecker = \_pattern _str -> True
  , configDefinitions    = mempty
  }

withSchema :: (s -> Validation s a) -> Validation s a Source

invalid :: String -> Validation schema a Source

Issue an error message.

valid :: Validation schema () Source

Validation passed.

check :: Lens' s (Maybe a) -> (a -> Validation s ()) -> Validation s () Source

Validate schema's property given a lens into that property and property checker.

sub :: t -> Validation t a -> Validation s a Source

Validate same value with different schema.

sub_ :: Getting a s a -> Validation a r -> Validation s r Source

Validate same value with a part of the original schema.

withRef :: Reference -> (Schema -> Validation s a) -> Validation s a Source

Validate value against a schema given schema reference and validation function.

validateWithSchema :: Value -> Validation Schema () Source

Validate JSON Value with Swagger Schema.