Skip to content

Commit

Permalink
export validation function (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolas Burkoff authored Jun 22, 2022
1 parent ee99ab4 commit 3e176e2
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 1 deletion.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export(set_keys)
export(teal_data)
export(teal_data_file)
export(to_relational_data)
export(validate_metadata)
import(shiny)
importFrom(digest,digest)
importFrom(formatters,var_labels)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# teal.data 0.1.1.9001

* Exported `validate_metadata` function.

# teal.data 0.1.1

### Miscellaneous
Expand Down
15 changes: 14 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,23 @@ check_pkg_quietly <- function(pckg, msg) {
invisible(NULL)
}

# validate metadata as a list of length one atomic

#' validate metadata as a list of length one atomic entries (or NULL)
#' @param metadata `object` to be checked
#' @return `NULL` or throw error
#' @examples
#'
#' validate_metadata(NULL)
#' validate_metadata(list(A = TRUE, B = 10, C = "test"))
#' \dontrun{
#' validate_metadata(list(a = 1:10))
#' }
#'
#' @export
validate_metadata <- function(metadata) {
checkmate::assert_list(metadata, any.missing = FALSE, names = "named", null.ok = TRUE)
lapply(names(metadata), function(name) {
checkmate::assert_atomic(metadata[[name]], len = 1, .var.name = name)
})
return(NULL)
}
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ reference:
- join_keys
- python_code
- read_script
- validate_metadata
- title: For Developers
subtitle: R6 Classes
desc: Abstract and concrete classes used to build teal functionality.
Expand Down
26 changes: 26 additions & 0 deletions man/validate_metadata.Rd

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

0 comments on commit 3e176e2

Please sign in to comment.