Skip to content

Commit e7ed141

Browse files
committed
Add missing parameter validation for epix_{as_of,slide}
1 parent 01531df commit e7ed141

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

R/archive.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,9 @@ epi_archive =
472472
if (max_version > self$versions_end) {
473473
Abort("`max_version` must be at most `self$versions_end`.")
474474
}
475+
if (!rlang::is_bool(all_versions)) {
476+
Abort("`all_versions` must be TRUE or FALSE.")
477+
}
475478
if (!is.na(self$clobberable_versions_start) && max_version >= self$clobberable_versions_start) {
476479
Warn('Getting data as of some recent version which could still be overwritten (under routine circumstances) without assigning a new version number (a.k.a. "clobbered"). Thus, the snapshot that we produce here should not be expected to be reproducible later. See `?epi_archive` for more info and `?epix_as_of` on how to muffle.',
477480
class="epiprocess__snapshot_as_of_clobberable_version")

R/grouped_epi_archive.R

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ grouped_epi_archive =
230230
}
231231
before <- vctrs::vec_cast(before, integer())
232232
if (length(before) != 1L || is.na(before) || before < 0L) {
233-
Abort("`before` must be length-1, non-NA, non-negative")
233+
Abort("`before` must be length-1, non-NA, non-negative.")
234234
}
235235

236236
# If a custom time step is specified, then redefine units
@@ -240,6 +240,20 @@ grouped_epi_archive =
240240
# Symbolize column name
241241
new_col = sym(new_col_name)
242242

243+
# Validate rest of parameters:
244+
if (!rlang::is_bool(as_list_col)) {
245+
Abort("`as_list_col` must be TRUE or FALSE.")
246+
}
247+
if (! (rlang::is_string(names_sep) || is.null(names_sep)) ) {
248+
Abort("`names_sep` must be a (single) string or NULL.")
249+
}
250+
if (!rlang::is_bool(all_rows)) {
251+
Abort("`all_rows` must be TRUE or FALSE.")
252+
}
253+
if (!rlang::is_bool(all_versions)) {
254+
Abort("`all_versions` must be TRUE or FALSE.")
255+
}
256+
243257
# Each computation is expected to output a data frame with either
244258
# one element/row total or one element/row per encountered
245259
# nongrouping, nontime, nonversion key value. These nongrouping,

0 commit comments

Comments
 (0)