R/assertions.R

Defines functions not_missing has_key

not_missing <- function(x) {
  !missing(x)
}

on_failure(not_missing) <- function(call, env) {
  paste0(
    "Missing `",
    crayon::blue(deparse(call$x)),
    "`."
  )
}

has_key <- function(x) {
  nchar(x) > 1
}

on_failure(has_key) <- function(call, env) {
  paste0(
    "Invalid `",
    crayon::blue(deparse(call$x)),
    "`."
  )
}
JohnCoene/gkg documentation built on Oct. 30, 2019, 7:56 p.m.