R/validators.R

Defines functions assert_index_class_is_allowed assert_index_exists_in_colnames validate_tbl_time

# Main validator
validate_tbl_time <- function(x) {
  assert_index_exists_in_colnames(x)
  assert_index_class_is_allowed(x)
  x
}

assert_index_exists_in_colnames <- function(x) {
  index_char <- get_index_char(x)
  assertthat::assert_that(
    index_char %in% colnames(x),
    msg = "Specified `index` is not a column of x"
  )
}

assert_index_class_is_allowed <- function(x) {
  index_char <- get_index_char(x)
  index_col <- x[[index_char]]
  assertthat::assert_that(
    inherits_allowed_datetime(index_col),
    msg = "Specified `index` is not time based"
  )
}

Try the tibbletime package in your browser

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

tibbletime documentation built on Feb. 16, 2023, 7:09 p.m.