% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/apply_audit_rules.R
\name{apply_audit_rules}
\alias{apply_audit_rules}
\title{Apply Data Audit Rules}
\usage{
apply_audit_rules(data, rules)
}
\arguments{
\item{data}{A data.frame.}

\item{rules}{An object of class \code{DataAuditRules}
created by \code{\link{audit_rules}}.}
}
\value{
An object of class \code{DataAuditRuleResult}.
}
\description{
Applies a set of validation rules created by
\code{\link{audit_rules}} to a data frame.
}
\details{
The function evaluates range, category, uniqueness,
required-value, and regular-expression rules.

Rules referring to variables that are not present in
\code{data} produce an error.
}
\examples{
dat <- data.frame(
  Animal_ID = c("A001", "A002", "A002", NA),
  Species = c("Dog", "Cat", "Horse", "Dog"),
  Age = c(5, 3, 40, 2),
  stringsAsFactors = FALSE
)

rules <- audit_rules(
  range = list(
    Age = c(0, 30)
  ),
  category = list(
    Species = c("Dog", "Cat", "Cattle")
  ),
  unique = "Animal_ID",
  required = "Animal_ID",
  pattern = list(
    Animal_ID = "^A[0-9]+$"
  )
)

apply_audit_rules(dat, rules)

}
