aeson-match-qq 1.5.2 → 1.5.3
raw patch · 4 files changed
+26/−6 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.markdown +7/−2
- aeson-match-qq.cabal +1/−1
- src/Aeson/Match/QQ.hs +1/−2
- src/Aeson/Match/QQ/Internal/Match.hs +17/−1
CHANGELOG.markdown view
@@ -1,7 +1,12 @@+1.5.3+=====++ * Minuscule Haddock improvements+ 1.5.2 ===== - * Add `prettyError`, a pretty printer for `Error`s (https://github.com/supki/aeson-match-qq/pull/23)+ * Add `prettyError`, a pretty printer for `Error`s (https://github.com/supki/aeson-match-qq/pull/24) 1.5.1 =====@@ -13,7 +18,7 @@ * Streamlined API. - * Sprinkled some CPP to support clients that have been made compatible+ * Sprinkled some CPP to support clients that have not been made compatible with Aeson 2.0 yet, so that they do not have to use a separate release (1.3.x) 1.4.3
aeson-match-qq.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: aeson-match-qq-version: 1.5.2+version: 1.5.3 synopsis: Declarative JSON matchers. description: See README.markdown category: Web
src/Aeson/Match/QQ.hs view
@@ -7,6 +7,7 @@ , MissingPathElem(..) , ExtraArrayValues(..) , ExtraObjectValues(..)+ , prettyError , Value(..) , Array@@ -17,8 +18,6 @@ , Nullable(..) , Path(..) , PathElem(..)-- , prettyError ) where import Data.String (IsString(..))
src/Aeson/Match/QQ/Internal/Match.hs view
@@ -72,7 +72,7 @@ -- | Test if a matcher matches a 'Aeson.Value'. match :: Value Aeson.Value- -- ^ A matcher+ -- ^ A matcher, constructed with 'qq' -> Aeson.Value -- ^ A 'Value' from aeson -> Either (NonEmpty Error) (HashMap Text Aeson.Value)@@ -277,12 +277,18 @@ throwE = eitherToValidation . Left . pure +-- | Various errors that can happen when a matcher tries to match a 'Aeson.Value'. data Error = Mismatch Mismatch+ -- ^ The type of the value is correct, but the value itself is wrong | Mistype Mismatch+ -- ^ The type of the value is wrong | MissingPathElem MissingPathElem+ -- ^ The request path is missing in the value | ExtraArrayValues ExtraArrayValues+ -- ^ Unexpected extra values in an array | ExtraObjectValues ExtraObjectValues+ -- ^ Unexpected extra key-value pairs in an object deriving (Show, Eq) instance PP.Pretty Error where@@ -337,6 +343,8 @@ , "value" .= v ] +-- | A generic error that covers cases where either the type of the value+-- is wrong, or the value itself does not match. data Mismatch = MkMismatch { path :: Path , matcher :: Value Aeson.Value@@ -359,6 +367,8 @@ , PP.hsep [" given:", ppJson given] ] +-- | This error covers the case where the requested path simply does not exist+-- in a 'Aeson.Value'. data MissingPathElem = MkMissingPathElem { path :: Path , missing :: PathElem@@ -378,6 +388,8 @@ , PP.hsep ["missing:", PP.pPrint missing] ] +-- | Unless an extendable matcher is used, any extra values in an array+-- missing in the matcher will trigger this error. data ExtraArrayValues = MkExtraArrayValues { path :: Path , values :: Vector Aeson.Value@@ -400,6 +412,8 @@ ] ] +-- | Unless an extendable matcher is used, any extra key-value pairs in+-- an object missing in the matcher will trigger this error. data ExtraObjectValues = MkExtraObjectValues { path :: Path , values :: HashMap Text Aeson.Value@@ -428,6 +442,7 @@ , PP.hsep ["value:", ppJson v] ] +-- | A path is a list of path elements. newtype Path = Path { unPath :: [PathElem] } deriving (Show, Eq, IsList, Aeson.ToJSON) @@ -435,6 +450,7 @@ pPrint = foldMap PP.pPrint . unPath +-- | A path element is either a key lookup in an object, or an index lookup in an array. data PathElem = Key Text | Idx Int