Safe Haskell | None |
---|---|
Language | Haskell2010 |
- type ValidationM e = ValidationT e Identity
- newtype ValidationT e m a = ValidationT {
- unValidationT :: EitherT e m a
- runValidator :: (a -> ValidationM e a) -> a -> Either e a
- runValidatorT :: Monad m => (a -> ValidationT e m a) -> a -> m (Either e a)
- (+>>) :: Monad m => (a -> ValidationT e m a) -> (a -> ValidationT e m a) -> a -> ValidationT e m a
- minLength :: (Monad m, HasLength a) => Int64 -> e -> a -> ValidationT e m a
- maxLength :: (Monad m, HasLength a) => Int64 -> e -> a -> ValidationT e m a
- lengthBetween :: (Monad m, HasLength a) => Int64 -> Int64 -> e -> a -> ValidationT e m a
- notEmpty :: (Monad m, HasLength a) => e -> a -> ValidationT e m a
- largerThan :: (Monad m, Ord a) => a -> e -> a -> ValidationT e m a
- smallerThan :: (Monad m, Ord a) => a -> e -> a -> ValidationT e m a
- valueBetween :: (Monad m, Ord a) => a -> a -> e -> a -> ValidationT e m a
- matchesRegex :: (Stringable a, Monad m) => Regex -> e -> a -> ValidationT e m a
- conformsPred :: Monad m => (a -> Bool) -> e -> a -> ValidationT e m a
- conformsPredM :: Monad m => (a -> m Bool) -> e -> a -> ValidationT e m a
- class HasLength a where
- class Stringable a where
- toString :: a -> String
- fromString :: String -> a
- toText :: a -> Text
- fromText :: Text -> a
- toLazyText :: a -> Text
- fromLazyText :: Text -> a
- toByteString :: a -> ByteString
- fromByteString :: ByteString -> a
- toLazyByteString :: a -> ByteString
- fromLazyByteString :: ByteString -> a
- toFilePath :: a -> FilePath
- fromFilePath :: FilePath -> a
- data Int64 :: *
- re :: QuasiQuoter
- mkRegexQQ :: [PCREOption] -> QuasiQuoter
- data Regex :: *
core monad and runners
type ValidationM e = ValidationT e Identity Source
The validation monad
newtype ValidationT e m a Source
The validation monad transformer
ValidationT | |
|
MonadTrans (ValidationT e) | |
(Monad m, Monoid e) => Alternative (ValidationT e m) | |
Monad m => Monad (ValidationT e m) | |
Monad m => Functor (ValidationT e m) | |
(Monad m, Monoid e) => MonadPlus (ValidationT e m) | |
Monad m => Applicative (ValidationT e m) |
runValidator :: (a -> ValidationM e a) -> a -> Either e a Source
Run a validation on a type a
runValidatorT :: Monad m => (a -> ValidationT e m a) -> a -> m (Either e a) Source
Run a validation on a type a
combinators
(+>>) :: Monad m => (a -> ValidationT e m a) -> (a -> ValidationT e m a) -> a -> ValidationT e m a Source
Combine two checks
checks
minLength :: (Monad m, HasLength a) => Int64 -> e -> a -> ValidationT e m a Source
Check that the value is at least N elements long
maxLength :: (Monad m, HasLength a) => Int64 -> e -> a -> ValidationT e m a Source
Check that the value is at maxium N elements long
lengthBetween :: (Monad m, HasLength a) => Int64 -> Int64 -> e -> a -> ValidationT e m a Source
Check that the value's length is between N and M
notEmpty :: (Monad m, HasLength a) => e -> a -> ValidationT e m a Source
Specialized minLength with N = 1
largerThan :: (Monad m, Ord a) => a -> e -> a -> ValidationT e m a Source
Check that a value is larger than N
smallerThan :: (Monad m, Ord a) => a -> e -> a -> ValidationT e m a Source
Check that a value is smaller than N
valueBetween :: (Monad m, Ord a) => a -> a -> e -> a -> ValidationT e m a Source
Check that a value is between M and N
matchesRegex :: (Stringable a, Monad m) => Regex -> e -> a -> ValidationT e m a Source
Checks that a value matches a regular expression
conformsPred :: Monad m => (a -> Bool) -> e -> a -> ValidationT e m a Source
Check that a value conforms a predicate
conformsPredM :: Monad m => (a -> m Bool) -> e -> a -> ValidationT e m a Source
Check that a value conforms a predicate
helper classes and types
class Stringable a where
fromString :: String -> a
toLazyText :: a -> Text
fromLazyText :: Text -> a
toByteString :: a -> ByteString
fromByteString :: ByteString -> a
toLazyByteString :: a -> ByteString
fromLazyByteString :: ByteString -> a
toFilePath :: a -> FilePath
fromFilePath :: FilePath -> a
data Int64 :: *
64-bit signed integer type
reexports
re :: QuasiQuoter
A QuasiQuoter for regular expressions that does a compile time check.
mkRegexQQ :: [PCREOption] -> QuasiQuoter
Returns a QuasiQuoter like re
, but with given PCRE options.