is_satisfying_funcs: Checks if a passed value satisfies one or more tests provided...

View source: R/is_satisfying_funcs.R

is_satisfying_funcsR Documentation

Checks if a passed value satisfies one or more tests provided as functions.

Description

Checks if a passed value satisfies one or more tests provided as functions.

Usage

is_satisfying_funcs(value, func_or_list)

Arguments

value

the value to verify

func_or_list

a function or (optionally named) list of functions. The function must accept a single argument (which will receive the value) and return either a logical (TRUE or FALSE), or an instance of qscheck::report.

Examples

## Not run: 
qscheck::assert(
   qscheck::is_satisfying_funcs(
     my_parameter,
     list(
        more_than_five = function(x) {
           # Short form. Returns a logical
           x > 5
        },
        less_than_two = function(x) {
           # expanded form. use success() and failure(reason)
           if (x < 2) {
             return(success())
           } else {
             return(failure("Value must be less than two"))
           }
        }
     )
   )
)

## End(Not run)


AstraZeneca/qscheck documentation built on Nov. 1, 2023, 4:45 a.m.