validate: Validate objects

validateR Documentation

Validate objects

Description

Validate objects

Usage

validate(., ..., .checklist = list(), .error_class = "validationError")

.f %checkout% .checks

Arguments

.

Object to validate.

...

Input-validation check formula(e).

.checklist

List of check formulae. (These are combined with check formulae provided via ....)

.error_class

Subclass of the error condition to be raised when an input validation error occurs (character).

.f

Interpreted function, i.e., closure.

.checks

List of check formulae, optionally containing a character vector named .error_class, corresponding to the similarly named argument.

Examples

## Not run: 
library(magrittr)

# Valid assertions: data frame returned (invisibly)
mtcars %>%
  validate(
    vld_all(~sapply(., is.numeric)),
    ~{nrow(.) > 10},
    vld_all(~c("mpg", "cyl") %in% names(.))
  )

# Invalid assertions: error raised
mtcars %>%
  validate(
    vld_all(~sapply(., is.numeric)),
    ~{nrow(.) > 1000},
    vld_all(~c("mpg", "cylinders") %in% names(.))
  )

## End(Not run)

egnha/valaddin documentation built on Nov. 3, 2023, 5:27 p.m.