Created
August 13, 2023 17:30
-
-
Save TransGirlCodes/d86d1a233a4575b3210a1f99a7467475 to your computer and use it in GitHub Desktop.
Testing use of validate_if inside of a box
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
box::use(./validate_if_box[...], data.table[...], data.validator[...]) | |
test_tbl <- data.table(a = 1:5, b = 6:10) | |
test_schema <- data.table(name = c("a", "b"), class = c("numeric", "numeric")) | |
validate_columns_exist(validate(test_tbl), test_schema) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
box::use(data.table[...], data.validator[...], assertr[...]) | |
#' @export | |
validate_columns_exist <- function (data, schema) { | |
validate_if( | |
data, | |
# Things only work if I change this to assertr::has_all_names(!!!schema$name), defying the point of box. | |
has_all_names(!!!schema$name), | |
description = "Required columns exist" | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment