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.gzfile
devtools::build()- Install
.tar.gzfile
install.packages("path_to_file/tar_gz_file", repos = NULL, type="source")The following list of validators are available:
is.not.NULLis.data.frameis.characteris.emptyis.not.emptyhas.one.rowis.UUID
There are two ways to access the validators:
- Use the library function to load the validators
- Create a new instance of the
Validatorcomponent using the package namespace
- Load the package
library(Validate)- Create new instance of the
Validatorcomponent
validator <- Validator()- Create new instance of the
Validatorcomponent
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.NULLvalidator 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."