serokell-util-0.10.0: General-purpose functions by Serokell

Safe HaskellNone
LanguageHaskell2010

Serokell.Util.Verify

Contents

Description

General-purpose utility functions

Synopsis

Documentation

Helpers

Verification

verifyGeneric :: [(Bool, Text)] -> VerificationRes Source #

This function takes list of (predicate, message) pairs and checks each predicate. If predicate is False it's considered an error. If there is at least one error this function returns VerFailure, otherwise VerSuccess is returned. It's useful to verify some data before using it. Example usage: `verifyGeneric [(checkA, "A is bad"), (checkB, "B is bad")]`

Prety printing

formatAllErrors :: NonEmpty Text -> Text Source #

Pretty printer for errors from VerFailure, all errors are printed.

formatFirstError :: NonEmpty Text -> Text Source #

Pretty printer for errors from VerFailure, only first error is printed.

verResFullF :: VerificationRes -> Text Source #

Format VerificationRes in a pretty way using all errors messages for VerFailure.

verResSingleF :: VerificationRes -> Text Source #

Format VerificationRes in a pretty way using only first message for VerFailure.