Skip to content

Commit

Permalink
feat: adds assertion to exported functions
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo committed Nov 23, 2023
1 parent 7ac63d2 commit 507d3f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions R/messages.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#' @return Output to Console
#' @export
xportr_logger <- function(message, type = "none", ...) {
assert_character(message)
assert_choice(verbose, choices = .internal_verbose_choices)

log_fun <- switch(type,
stop = abort,
warn = warn,
Expand All @@ -28,6 +31,9 @@ xportr_logger <- function(message, type = "none", ...) {
#' @return Output to Console
#' @export
var_names_log <- function(tidy_names_df, verbose) {
assert_data_frame(tidy_names_df)
assert_choice(verbose, choices = .internal_verbose_choices)

only_renames <- tidy_names_df %>%
filter(original_varname != renamed_var) %>%
mutate(
Expand Down
4 changes: 2 additions & 2 deletions R/utils-xportr.R
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ xpt_validate_var_names <- function(varnames,
#'
#' @export
xpt_validate <- function(data) {
assert_data_frame(data)

err_cnd <- character()

# 1.0 VARIABLES ----
Expand Down Expand Up @@ -310,8 +312,6 @@ xpt_validate <- function(data) {
#' @return A string representing the domain
#' @noRd
get_domain <- function(.df, df_arg, domain) {
assert_string(domain, null.ok = TRUE)

if (identical(df_arg, ".")) {
df_arg <- get_pipe_call()
}
Expand Down

0 comments on commit 507d3f9

Please sign in to comment.