Skip to content

Commit

Permalink
validate remaining parameters in read functions
Browse files Browse the repository at this point in the history
closes #208
  • Loading branch information
wibeasley committed May 29, 2018
1 parent 8041a3f commit f075aea
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 22 deletions.
20 changes: 12 additions & 8 deletions R/redcap-read-oneshot-eav.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,24 +111,28 @@ redcap_read_oneshot_eav <- function(

checkmate::assert_character(redcap_uri , any.missing=F, len=1, pattern="^.{1,}$")
checkmate::assert_character(token , any.missing=F, len=1, pattern="^.{1,}$")
# records
# fields
checkmate::assert_atomic(records , any.missing=T, min.len=0)
checkmate::assert_character(records_collapsed , any.missing=T, len=1, pattern="^.{0,}$", null.ok=T)
checkmate::assert_character(fields , any.missing=T, min.len=1, pattern="^.{1,}$", null.ok=T)
checkmate::assert_character(fields_collapsed , any.missing=T, len=1, pattern="^.{0,}$", null.ok=T)
# forms
# events
# forms_collapsed
checkmate::assert_character(events , any.missing=T, min.len=1, pattern="^.{1,}$", null.ok=T)
checkmate::assert_character(events_collapsed , any.missing=T, len=1, pattern="^.{0,}$", null.ok=T)
checkmate::assert_character(raw_or_label , any.missing=F, len=1)
checkmate::assert_subset( raw_or_label , c("raw", "label"))
checkmate::assert_character(raw_or_label_headers , any.missing=F, len=1)
checkmate::assert_subset( raw_or_label_headers , c("raw", "label"))
# exportCheckboxLabel
# export_checkbox_label --irrelevant in EAV
# returnFormat
# export_survey_fields
checkmate::assert_logical( export_data_access_groups , any.missing=F, len=1)
checkmate::assert_character(filter_logic , any.missing=F, len=1, pattern="^.{0,}$")
#
# guess_type
# verbose
# config_options
# id_position
#checkmate::assert_logical( guess_type , any.missing=F, len=1)
#checkmate::assert_integerish(guess_max , any.missing=F, len=1, lower=1)
checkmate::assert_logical( verbose , any.missing=F, len=1, null.ok=T)
checkmate::assert_list( config_options , any.missing=T, len=1, null.ok=T)

token <- sanitize_token(token)
validate_field_names(fields)
Expand Down
14 changes: 9 additions & 5 deletions R/redcap-read-oneshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,14 @@ redcap_read_oneshot <- function(

checkmate::assert_character(redcap_uri , any.missing=F, len=1, pattern="^.{1,}$")
checkmate::assert_character(token , any.missing=F, len=1, pattern="^.{1,}$")
# records
# fields
checkmate::assert_atomic(records , any.missing=T, min.len=0)
checkmate::assert_character(records_collapsed , any.missing=T, len=1, pattern="^.{0,}$", null.ok=T)
checkmate::assert_character(fields , any.missing=T, min.len=1, pattern="^.{1,}$", null.ok=T)
checkmate::assert_character(fields_collapsed , any.missing=T, len=1, pattern="^.{0,}$", null.ok=T)
# forms
# events
# forms_collapsed
checkmate::assert_character(events , any.missing=T, min.len=1, pattern="^.{1,}$", null.ok=T)
checkmate::assert_character(events_collapsed , any.missing=T, len=1, pattern="^.{0,}$", null.ok=T)
checkmate::assert_character(raw_or_label , any.missing=F, len=1)
checkmate::assert_subset( raw_or_label , c("raw", "label"))
checkmate::assert_character(raw_or_label_headers , any.missing=F, len=1)
Expand All @@ -115,8 +119,8 @@ redcap_read_oneshot <- function(
#
checkmate::assert_logical( guess_type , any.missing=F, len=1)
checkmate::assert_integerish(guess_max , any.missing=F, len=1, lower=1)
# verbose
# config_options
checkmate::assert_logical( verbose , any.missing=F, len=1, null.ok=T)
checkmate::assert_list( config_options , any.missing=T, len=1, null.ok=T)

token <- sanitize_token(token)
validate_field_names(fields)
Expand Down
19 changes: 11 additions & 8 deletions R/redcap-read.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
#' token <- "9A81268476645C4E5F03428B8AC3AA7B"
#' redcap_read(batch_size=2, redcap_uri=uri, token=token)
#' }
#'

redcap_read <- function(
batch_size = 100L,
Expand Down Expand Up @@ -97,23 +96,27 @@ redcap_read <- function(

checkmate::assert_character(redcap_uri , any.missing=F, len=1, pattern="^.{1,}$")
checkmate::assert_character(token , any.missing=F, len=1, pattern="^.{1,}$")
# records
# fields
checkmate::assert_atomic(records , any.missing=T, min.len=0)
checkmate::assert_character(records_collapsed , any.missing=T, len=1, pattern="^.{0,}$", null.ok=T)
checkmate::assert_character(fields , any.missing=T, min.len=1, pattern="^.{1,}$", null.ok=T)
checkmate::assert_character(fields_collapsed , any.missing=T, len=1, pattern="^.{0,}$", null.ok=T)
# forms
# events
# forms_collapsed
checkmate::assert_character(events , any.missing=T, min.len=1, pattern="^.{1,}$", null.ok=T)
checkmate::assert_character(events_collapsed , any.missing=T, len=1, pattern="^.{0,}$", null.ok=T)
checkmate::assert_character(raw_or_label , any.missing=F, len=1)
checkmate::assert_subset( raw_or_label , c("raw", "label"))
checkmate::assert_character(raw_or_label_headers , any.missing=F, len=1)
checkmate::assert_subset( raw_or_label_headers , c("raw", "label"))
checkmate::assert_logical( export_checkbox_label , any.missing=F, len=1)
# returnFormat
# export_survey_fields
checkmate::assert_logical( export_survey_fields , any.missing=F, len=1)
checkmate::assert_logical( export_data_access_groups , any.missing=F, len=1)
#
checkmate::assert_logical( guess_type , any.missing=F, len=1)
# verbose
# config_options
# id_position
checkmate::assert_logical( verbose , any.missing=F, len=1, null.ok=T)
checkmate::assert_list( config_options , any.missing=T, len=1, null.ok=T)
checkmate::assert_integer( id_position , any.missing=F, len=1, lower=1L)

token <- sanitize_token(token)
validate_field_names(fields)
Expand Down
1 change: 0 additions & 1 deletion man/redcap_read.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f075aea

Please sign in to comment.