ganeti
Safe HaskellNone

Ganeti.Utils.Validate

Description

A validation monad and corresponding utilities

The monad allows code to emit errors during checking.

Synopsis

Documentation

newtype ValidationMonadT m a Source #

Monad for running validation checks.

Constructors

ValidationMonad 

Fields

Instances

Instances details
Monad m => Monad (ValidationMonadT m) # 
Instance details

Defined in Ganeti.Utils.Validate

Functor m => Functor (ValidationMonadT m) # 
Instance details

Defined in Ganeti.Utils.Validate

Methods

fmap :: (a -> b) -> ValidationMonadT m a -> ValidationMonadT m b

(<$) :: a -> ValidationMonadT m b -> ValidationMonadT m a

Applicative m => Applicative (ValidationMonadT m) # 
Instance details

Defined in Ganeti.Utils.Validate

report :: Monad m => String -> ValidationMonadT m () Source #

An utility function that emits a single message into a validation monad.

reportIf :: Monad m => Bool -> String -> ValidationMonadT m () Source #

An utility function that conditionally emits a message into a validation monad. It's a combination of when and report.

runValidateT :: Monad m => ValidationMonadT m a -> m (a, [String]) Source #

An utility function that runs a monadic validation action and returns the list of errors.

runValidate :: ValidationMonad a -> (a, [String]) Source #

An utility function that runs a monadic validation action and returns the list of errors.

execValidateT :: Monad m => ValidationMonadT m () -> m [String] Source #

An utility function that runs a monadic validation action and returns the list of errors.

execValidate :: ValidationMonad () -> [String] Source #

An utility function that runs a validation action and returns the list of errors.

throwIfErrors :: MonadError String m => (a, [String]) -> m a Source #

A helper function for throwing an exception if a list of errors is non-empty.

evalValidate :: MonadError String m => ValidationMonad a -> m a Source #

Runs a validation action and if there are errors, combine them into an exception.

evalValidateT :: MonadError String m => ValidationMonadT m a -> m a Source #

Runs a validation action and if there are errors, combine them into an exception.

class Validatable a where Source #

A typeclass for objects that can be validated. That is, they can perform an internal check and emit any errors encountered. Emiting no errors means the object is valid.

Methods

validate :: a -> ValidationMonad () Source #

Instances

Instances details
Validatable LogicalVolume #

Check the constraints for VG/LV names (except the /dev/ check).

Instance details

Defined in Ganeti.Objects.Disk

validate' :: Validatable a => a -> ValidationMonad a Source #

Run validation and return the original value as well. the original value.