keuringsdienst-1.0.0.5
Safe HaskellSafe-Inferred
LanguageGHC2021

Keuringsdienst

Synopsis

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.

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.

Constructors

Success 
Failure err 

Instances

Instances details
Monoid ValidationResult Source # 
Instance details

Defined in Keuringsdienst

Semigroup ValidationResult Source # 
Instance details

Defined in Keuringsdienst

FromJSON err => FromJSON (Validation err) Source # 
Instance details

Defined in Keuringsdienst

ToJSON err => ToJSON (Validation err) Source # 
Instance details

Defined in Keuringsdienst

Generic (Validation err) Source # 
Instance details

Defined in Keuringsdienst

Associated Types

type Rep (Validation err) :: Type -> Type #

Methods

from :: Validation err -> Rep (Validation err) x #

to :: Rep (Validation err) x -> Validation err #

Show err => Show (Validation err) Source # 
Instance details

Defined in Keuringsdienst

Methods

showsPrec :: Int -> Validation err -> ShowS #

show :: Validation err -> String #

showList :: [Validation err] -> ShowS #

Eq err => Eq (Validation err) Source # 
Instance details

Defined in Keuringsdienst

Methods

(==) :: Validation err -> Validation err -> Bool #

(/=) :: Validation err -> Validation err -> Bool #

type Rep (Validation err) Source # 
Instance details

Defined in Keuringsdienst

type Rep (Validation err) = D1 ('MetaData "Validation" "Keuringsdienst" "keuringsdienst-1.0.0.5-Lton8bqyV7MHpHGzg2LYfC" 'False) (C1 ('MetaCons "Success" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Failure" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 err)))

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