4444# ' @importFrom purrr map_chr map_lgl
4545create_epidata_call <- function (endpoint , params , meta = NULL ,
4646 only_supports_classic = FALSE ) {
47- stopifnot(is.character( endpoint ), length( endpoint ) = = 1 )
48- stopifnot(is.list( params ) )
49- stopifnot(is.null( meta ) || is.list( meta ) )
50- stopifnot(all(map_lgl( meta , ~ inherits( .x , " EpidataFieldInfo " ))) )
51- stopifnot(is.logical( only_supports_classic ), length( only_supports_classic ) == 1 )
47+ checkmate :: assert_character( endpoint , len = 1 )
48+ checkmate :: assert_list( params )
49+ checkmate :: assert_list( meta , null.ok = TRUE )
50+ checkmate :: assert_logical( only_supports_classic , len = 1 )
51+ checkmate :: assert_true(all(map_lgl( meta , ~ inherits( .x , " EpidataFieldInfo " ))) )
5252
5353 if (length(unique(meta )) != length(meta )) {
5454 cli :: cli_abort(
@@ -73,6 +73,15 @@ create_epidata_call <- function(endpoint, params, meta = NULL,
7373 )
7474 }
7575
76+ # TODO: Something like this in the future? We set up the categories
77+ # but we don't actually validate them yet?
78+ # for (field in names(params)) {
79+ # value <- params[[field]]
80+ # if (meta[[field]]$type == "categorical") {
81+ # checkmate::assert_subset(value, meta[[field]]$categories)
82+ # }
83+ # }
84+
7685 if (is.null(meta )) {
7786 meta <- list ()
7887 }
0 commit comments