-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea5a8b0
commit 0e7d529
Showing
1 changed file
with
31 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
stopifnotMessage = function(...) { | ||
ok = TRUE | ||
errors = list() | ||
listargs = list(...) | ||
for (i in 1:length(listargs)) { | ||
if (listargs[i] == FALSE) { | ||
errors[[""]] = names(listargs)[i] | ||
ok = FALSE | ||
} | ||
} | ||
if (ok == FALSE) { | ||
stop(paste0("\n\nWhen validating the arguments:\n ", paste(errors, collapse="\n "))) | ||
} | ||
} | ||
|
||
checkLogical = function(x) { | ||
return (is.null(x) || (length(x) == 1 && is.logical(x))) | ||
} | ||
|
||
checkInteger = function(x) { | ||
x_int = as.integer(x) | ||
return (is.null(x) || (length(x_int) == 1 && is.integer(x_int) && !is.na(x_int))) | ||
} | ||
|
||
checkParentDir = function(x, optional=FALSE) { | ||
if (optional && is.null(x)) { | ||
return (TRUE) | ||
} | ||
dirName = fs::path_dir(x) | ||
return (fs::dir_exists(dirName)[[1]]) | ||
} | ||
stopifnotMessage = function(...) { | ||
ok = TRUE | ||
errors = list() | ||
listargs = list(...) | ||
for (i in seq_len(listargs)) { | ||
if (listargs[i] == FALSE) { | ||
errors[[""]] = names(listargs)[i] | ||
ok = FALSE | ||
} | ||
} | ||
if (ok == FALSE) { | ||
stop(paste0("\n\nWhen validating the arguments:\n ", paste(errors, collapse="\n "))) | ||
} | ||
} | ||
|
||
checkLogical = function(x) { | ||
return (is.null(x) || (length(x) == 1 && is.logical(x))) | ||
} | ||
|
||
checkInteger = function(x) { | ||
x_int = as.integer(x) | ||
return (is.null(x) || (length(x_int) == 1 && is.integer(x_int) && !is.na(x_int))) | ||
} | ||
|
||
checkParentDir = function(x, optional=FALSE) { | ||
if (optional && is.null(x)) { | ||
return (TRUE) | ||
} | ||
dirName = fs::path_dir(x) | ||
return (fs::dir_exists(dirName)[[1]]) | ||
} |