Skip to content

FlippieCoetser/Validate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Validate

r-universe

Installation

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:

Install via GitHub

  1. Use Devtools
devtools::install_github("https://github.com/FlippieCoetser/Validate")

Build and Install Locally

  1. Generate .tar.gz file
devtools::build()
  1. Install .tar.gz file
install.packages("path_to_file/tar_gz_file", repos = NULL, type="source")

Usage

Validators

The following list of validators are available:

  1. is.not.NULL
  2. is.data.frame
  3. is.character
  4. is.empty
  5. is.not.empty
  6. has.one.row
  7. is.UUID

There are two ways to access the validators:

  1. Use the library function to load the validators
  2. Create a new instance of the Validator component using the package namespace

Using the library function

  1. Load the package
library(Validate)
  1. Create new instance of the Validator component
validator <- Validator()

Using the package namespace

  1. Create new instance of the Validator component
validator <- Validate::Validator()

Using the validators

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.

  1. Define test variable
variable <- NULL
  1. 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."

About

Generic Validation Package

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages