-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from hubverse-org/ak/round-id-regex-val/68
Add round_id expected pattern match check
- Loading branch information
Showing
14 changed files
with
1,047 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
validate_round_id_pattern <- function(x) { | ||
stringr::str_detect( | ||
x, | ||
"^(\\d{4}-\\d{2}-\\d{2})$|^[A-Za-z0-9_]+$" | ||
) | ||
} | ||
|
||
# This function expects a list representation of the task ID variable values | ||
# specified in `round_id` when `round_id_from_variable` is `true.` | ||
# Returns a list with `required` and `optional` elements containg either the | ||
# invalid values identified by the `validate_round_id_pattern` function or NULL. | ||
invalid_round_id_var_patterns <- function(round_id_var_vals) { | ||
purrr::map( | ||
round_id_var_vals, | ||
\(.x) { | ||
if (is.null(.x)) { | ||
return(NULL) | ||
} | ||
valid <- validate_round_id_pattern(.x) | ||
invalid <- .x[!valid] | ||
if (length(invalid) == 0L) { | ||
return(NULL) | ||
} | ||
invalid | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.