Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
output in a character vector with a slightly different format (#39)
- add `ignore_val_err` parameter in the `validate_submission()` function to
ignore stopping the validation if any `[valid_vals]` error (#40)
- add parameter `store_msg_val()` function to remove valid check (and non
compound id check) on output of the function (#44)

# SMHvalidation 1.0.0

Expand Down
13 changes: 11 additions & 2 deletions R/imports-hubValidations.R
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,13 @@ is_check_class <- function(x,
#' Store validation output in a simple object
#'
#' @param msg validation output
#' @param rm_valid_check Boolean, remove valid check and `spl_non_compound`
#' output, by default FALSE.
#'
#' @importFrom dplyr case_when
#' @importFrom purrr map_chr
#' @export
store_msg_val <- function(msg) {
store_msg_val <- function(msg, rm_valid_check = FALSE) {
txt <- paste(
dplyr::case_when(is_check_class(msg, "check_success") ~ "\U002705",
is_check_class(msg, "check_failure") ~ "\U002757",
Expand All @@ -257,7 +259,14 @@ store_msg_val <- function(msg) {
TRUE ~ "*"),
paste0("[", names(msg), "]"),
purrr::map_chr(msg, "message"),
sep = ": ", collapse = "\n"
sep = ": "
)
if (rm_valid_check)
txt <- purrr::discard(txt, ~grepl("\U002705|spl_non_compound", .x))
if (length(txt) > 0) {
txt <- paste(txt, collapse = "\n")
} else {
txt <- "No issue reported"
}
txt
}
5 changes: 4 additions & 1 deletion man/store_msg_val.Rd

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

3 changes: 3 additions & 0 deletions tests/testthat/test_submission.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ test_that("Test validation process", {
expect_contains(attr(check$req_vals, "class"), c("error", "check_error"))
msg <- store_msg_val(check)
expect_true(grepl("\U001F6AB.*\U002705", msg))
msg2 <- store_msg_val(check, rm_valid_check = TRUE)
expect_true(nchar(msg) > nchar(msg2))
expect_false(grepl("\U002705", msg2))

## Additional data
df <- rbind(df0,
Expand Down