validate: Validate objects

Description Usage Arguments Examples

Description

Validate objects

Usage

1
2
3
validate(., ..., error_class = NULL)

validator(..., error_class = NULL)

Arguments

.

Object to validate.

...

Input validation checks.

error_class

Character vector of the error subclass to signal if validation fails. If NULL (the default), the error subclass is objectValidationError.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# All assertions valid: data frame returned (invisibly)
validate(mtcars,
         is.data.frame,
         chk_all_map(is.numeric),
         chk_gt(10, nrow(.)),
         chk_has_names(c("mpg", "cyl")))

# Some assertions invalid: diagnostic error raised
## Not run: 
validate(mtcars,
         is.matrix,
         chk_all_map(is.numeric),
         chk_gt(1000, nrow(.)),
         chk_has_name("cylinders"))
## End(Not run)

egnha/rong documentation built on May 7, 2019, 9:48 p.m.