R/assert-has-attributes.R

Defines functions assert_has_any_attributes assert_has_all_attributes

Documented in assert_has_all_attributes assert_has_any_attributes

#' @rdname has_attributes
#' @export
#' @include imports.R
assert_has_all_attributes <- function(x, attrs, 
  severity = getOption("assertive.severity", "stop"))
{                                       
  msg <- gettextf(
    "%s does not have all the attributes %s.", 
    get_name_in_parent(x), 
    toString(sQuote(attrs))
  )
  assert_engine(
    has_attributes, 
    x, 
    attrs = attrs, 
    msg = msg, 
    severity = severity
  )
}

#' @rdname has_attributes
#' @export
assert_has_any_attributes <- function(x, attrs, 
  severity = getOption("assertive.severity", "stop"))
{                                       
  msg <- gettextf(
    "%s does not have any of the attributes %s.", 
    get_name_in_parent(x), 
    toString(sQuote(attrs))
    )
  assert_engine(
    has_attributes, 
    x, 
    attrs = attrs, 
    msg = msg, 
    what = "any",
    severity = severity
  )
}

Try the assertive.properties package in your browser

Any scripts or data that you put into this service are public.

assertive.properties documentation built on April 21, 2022, 5:13 p.m.