Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- type ValidationResult = Validation [ErrMsg]
- newtype ValidationRule a = ValidationRule {
- performValidation :: a -> ValidationResult
- data Validation err
- keuren :: a -> ValidationRule a -> ValidationResult
- misschienKeuren :: Maybe a -> ValidationRule a -> ValidationResult
- validate :: a -> ValidationRule a -> ValidationResult
- maybeValidate :: Maybe a -> ValidationRule a -> ValidationResult
- ofDitOfDat :: ValidationRule a -> ValidationRule a -> ValidationRule a
- orThisOrThat :: ValidationRule a -> ValidationRule a -> ValidationRule a
- (*||*) :: ValidationRule a -> ValidationRule a -> ValidationRule a
- (|??|) :: Maybe a -> ValidationRule a -> ValidationResult
- (|?|) :: a -> ValidationRule a -> ValidationResult
Core types
type ValidationResult = Validation [ErrMsg] Source #
ValidationResult is the data type of choice for now, since we have chosen to implement the library in a way that it will return a [Text] as context for validation failures.
newtype ValidationRule a Source #
Data type representing a composable validation rule to be applied on a certain data.
Instances
Monoid (ValidationRule a) Source # | |
Defined in Keuringsdienst mempty :: ValidationRule a # mappend :: ValidationRule a -> ValidationRule a -> ValidationRule a # mconcat :: [ValidationRule a] -> ValidationRule a # | |
Semigroup (ValidationRule x) Source # | |
Defined in Keuringsdienst (<>) :: ValidationRule x -> ValidationRule x -> ValidationRule x # sconcat :: NonEmpty (ValidationRule x) -> ValidationRule x # stimes :: Integral b => b -> ValidationRule x -> ValidationRule x # |
data Validation err Source #
Core data type representing the outcome of a validation, which can be a success, or a failure with more information about the failure.
Instances
Operators
keuren :: a -> ValidationRule a -> ValidationResult Source #
This function applies a validation rule to a value. Stands for validate/judge in Dutch.
misschienKeuren :: Maybe a -> ValidationRule a -> ValidationResult Source #
This function applies a validation rule to a value when it is a Just and defaults to a Success in case of a Nothing. Stands for maybe validate/judge in Dutch.
validate :: a -> ValidationRule a -> ValidationResult Source #
Alias to the keuren operator
maybeValidate :: Maybe a -> ValidationRule a -> ValidationResult Source #
Alias to the misschienKeuren operator
ofDitOfDat :: ValidationRule a -> ValidationRule a -> ValidationRule a Source #
If one of the validations has a successful result, then the validation is a success. Stands for or this or that in Dutch.
orThisOrThat :: ValidationRule a -> ValidationRule a -> ValidationRule a Source #
Alias to the ofDitOfDat operator
(*||*) :: ValidationRule a -> ValidationRule a -> ValidationRule a infixl 6 Source #
ofDitOfDat operator
(|??|) :: Maybe a -> ValidationRule a -> ValidationResult infixl 8 Source #
misschienKeuren operator
(|?|) :: a -> ValidationRule a -> ValidationResult infixl 8 Source #
keuren operator