packages feed

validity 0.5.0.0 → 0.6.0.0

raw patch · 2 files changed

+29/−19 lines, 2 files

Files

src/Data/Validity.hs view
@@ -44,6 +44,7 @@     , declare     , annotate     , delve+    , decorate     , invalid     , valid     -- * Utilities@@ -172,11 +173,16 @@  instance Validity ValidationChain +-- | The result of validating a value.+--+-- `mempty` means the value was valid.+--+-- This type intentionally doesn't have a `Validity` instance to make sure+-- you can never accidentally use `annotate` or `delve` twice. newtype Validation = Validation     { unValidation :: [ValidationChain]     } deriving (Show, Eq, Generic) -instance Validity Validation #if MIN_VERSION_base(4,11,0) instance Semigroup Validation where     (Validation v1) <> (Validation v2) = Validation $ v1 ++ v2@@ -215,6 +221,26 @@ declare :: String -> Bool -> Validation declare = flip check +-- | Declare a sub-part as a necessary part for validation, and annotate it with a name.+--+-- Example:+--+-- > validate (a, b) =+-- >     mconcat+-- >         [ annotate a "The first element of the tuple"+-- >         , annotate b "The second element of the tuple"+-- >         ]+annotate :: Validity a => a -> String -> Validation+annotate = annotateValidation . validate++-- | 'annotate', but with the arguments flipped.+delve :: Validity a => String -> a -> Validation+delve = flip annotate++-- | Decorate a validation with a location+decorate :: String -> Validation -> Validation+decorate = flip annotateValidation+ -- | Construct a trivially invalid 'Validation' -- -- Example:@@ -234,22 +260,6 @@  valid :: Validation valid = mempty---- | Declare a sub-part as a necessary part for validation, and annotate it with a name.------ Example:------ > validate (a, b) =--- >     mconcat--- >         [ annotate a "The first element of the tuple"--- >         , annotate b "The second element of the tuple"--- >         ]-annotate :: Validity a => a -> String -> Validation-annotate = annotateValidation . validate---- | 'annotate', but with the arguments flipped.-delve :: Validity a => String -> a -> Validation-delve = flip annotate  -- | Any tuple of things is valid if both of its elements are valid instance (Validity a, Validity b) => Validity (a, b) where
validity.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: a87e6dba549df499f2c199dd442f9cceacbeb4a8f99bd95f89739fbe810db31a+-- hash: 0352fc096299ba22bf145acdce658a27d3bf5898a040f8b0829d6aaa82332fd2  name:           validity-version:        0.5.0.0+version:        0.6.0.0 synopsis:       Validity typeclass description:    For more info, see <https://github.com/NorfairKing/validity the readme>.                 .