At the time of writing this README, this Validate
R-Package is not available on CRAN. Use devtools
to either install from GitHub or Build and Install locally:
- Use Devtools
devtools::install_github("https://github.com/FlippieCoetser/Validate")
- Generate
.tar.gz
file
devtools::build()
- Install
.tar.gz
file
install.packages("path_to_file/tar_gz_file", repos = NULL, type="source")
The following list of validators are available:
is.not.NULL
is.data.frame
is.character
is.empty
is.not.empty
has.one.row
is.UUID
There are two ways to access the validators:
- Use the library function to load the validators
- Create a new instance of the
Validator
component using the package namespace
- Load the package
library(Validate)
- Create new instance of the
Validator
component
validator <- Validator()
- Create new instance of the
Validator
component
validator <- Validate::Validator()
The validator
instance created below can be used to perform validation. For example, test if a variable is not null and throw an error is the variable is NULL.
- Define test variable
variable <- NULL
- Use the
is.not.NULL
validator to test if the variable is not NULL
result <- variable |> validator[['is.not.NULL']]('variable')
Because the variable is NULL, an error will the thrown with the following message:
"Argument.NULL: 'variable' cannot not be NULL."