tonyfischetti/assertr

Multiclass assertion of columns

AleKoure opened this issue · 1 comments

When a column has multiple classes, it is challenging to verify with has_class().

e.g. the following code produces an error

library(assertr)

time_df <- data.frame(time_var = Sys.time())
time_df |> verify(has_class("time_var", class = c("POSIXct", "POSIXt")))

To fully solve the problem I think we need some functions similar to expect_s3_class() and expect_type().

We can "hack" S3 classes with:

library(assertr)

time_df <- data.frame(time_var = Sys.time())
time_df |> verify(has_class("time_var", class = list(c("POSIXct", "POSIXt"))))