| Title: | Tools to validate data based on business validation rules |
|---|---|
| Description: | Provides tools to validate data based on business validation rules |
| Authors: | Emmanuel Blondel [aut, cre] (ORCID: <https://orcid.org/0000-0002-5870-5762>), Alexandre Bennici [aut] (ORCID: <https://orcid.org/0000-0003-2160-3487>) |
| Maintainer: | Emmanuel Blondel <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.20260710 |
| Built: | 2026-07-10 13:03:33 UTC |
| Source: | https://github.com/fdiwg/vrule |
column_spec
column_spec
namename
urnurn
dimensiondimension
aliasesaliases
requiredrequired
rulesrules
new()
Initializes a column specification
column_spec$new(obj = NULL)
objobject of class list
setName()
set name
column_spec$setName(name)
namename
setURN()
set URN
column_spec$setURN(urn)
urnurn
isDimension()
Set if the column is a dimension
column_spec$isDimension(isDimension)
isDimensionisDimension
setAliases()
Set aliases
column_spec$setAliases(aliases)
aliasesaliases
setRequired()
Set if the column is required
column_spec$setRequired(required)
requiredrequired
addRule()
Adds a validation rule
column_spec$addRule(rule)
rulerule
validate()
Method to validate column data
column_spec$validate(values, rows)
valuesvalues
rowsrows
a validation report, object of class vrule_report
hasCodelist()
Indicates if column specification includes a codelist validation rule
column_spec$hasCodelist()
TRUE if it includes codelist validation, FALSE otherwise
clone()
The objects of this class are cloneable with this method.
column_spec$clone(deep = FALSE)
deepWhether to make a deep clone.
create_vrule_report
create_vrule_report(valid, category, rule, type, message)create_vrule_report(valid, category, rule, type, message)
valid |
valid |
category |
category |
rule |
rule |
type |
type |
message |
message |
decodeVrules
decodeVrules(json)decodeVrules(json)
json |
json object |
format_spec
format_spec
nameformat name
urnurn
titletitle
typetpe
column_specscolumn specifications
new()
Initializes a format specification from a JSON list object
format_spec$new(file = NULL, obj = NULL, json = NULL)
setName()
Set name
format_spec$setName(name)
namename
setURN()
Set URN
format_spec$setURN(urn)
urnurn
setTitle()
Set title
format_spec$setTitle(title)
titletitle
setType()
Set type
format_spec$setType(type)
typetype
addColumnSpec()
Adds a column specification
format_spec$addColumnSpec(column_spec)
column_specan object of class column_spec
getColumnSpecByName()
Get column specification by name
format_spec$getColumnSpecByName(name)
namename
an object of class column_spec, or NULL if no column specification is found
getColumnSpecByURN()
Get column specification by URN
format_spec$getColumnSpecByURN(urn)
urnurn
an object of class column_spec, or NULL if no column specification is found
getColumnSpecByAlias()
Get column specification by alias
format_spec$getColumnSpecByAlias(alias)
aliasalias
an object of class column_spec, or NULL if no column specification is found
getColumnSpec()
Get column specification
format_spec$getColumnSpec(column)
columncolumn name or alias
an object of class column_spec, or NULL if no column specification is found
validateStructure()
Applies data structure validation
format_spec$validateStructure(data)
dataobject of class data.frame or tibble
an object of class data.frame if any data structure validation issue is found (ERROR or WARNING), or NULL if valid
validateSeries()
Applies data series validation
format_spec$validateSeries(data)
dataobject of class data.frame or tibble
an object of class data.frame if any data series validation issue is found (ERROR or WARNING), or NULL if valid
validateContent()
Applies data content validation
format_spec$validateContent(
data,
mode = c("column", "pair"),
parallel = FALSE,
...
)dataobject of class data.frame or tibble
modevalidation mode, either "column" (default) or "pair"
parallelwhether the validation should be run as parallel (default FALSE)
...any other arg
an object of class data.frame
validate()
Applies data validation
format_spec$validate(data, mode = c("column", "pair"), parallel = FALSE, ...)dataobject of class data.frame or tibble
modevalidation mode, either "column" (default) or "pair"
parallelwhether the validation should be run as parallel (default FALSE)
...any other arg
an object of class data.frame
display_as_handsontable()
Display data and validation report as Handsontable
format_spec$display_as_handsontable(data, report, ...)
datadata
reportreport
...any other arg
an object of class rhandsontable
validate_and_display_as_handsontable()
Applies data validation
format_spec$validate_and_display_as_handsontable( data, parallel = FALSE, read_only = TRUE, use_css_classes = FALSE, ... )
dataobject of class data.frame or tibble
parallelwhether the validation should be run as parallel (default FALSE)
read_onlyread only
use_css_classesuse css classes
...any other arg
an object of class rhandsontable
standardizeStructure()
Standardize structure
format_spec$standardizeStructure(data, exclude_unused = TRUE)
datadata
exclude_unusedexclude unsed columns
the standardized data structure
standardizeContent()
Standardize content
format_spec$standardizeContent(data)
datadata
the standardized data
createTemplate()
Creates template based on the format specification, including a template structure and eventual reference data files (codelists)
format_spec$createTemplate(use_aliases = FALSE, dir)
use_aliasesuse aliases?
dirdirectory where to save the template
the path of the output template (as ZIP file)
clone()
The objects of this class are cloneable with this method.
format_spec$clone(deep = FALSE)
deepWhether to make a deep clone.
get the list of classes inheriting a given super class provided by its name
getClassesInheriting(classname, extended, pretty)getClassesInheriting(classname, extended, pretty)
classname |
the name of the superclass for which inheriting sub-classes have to be listed |
extended |
whether we want to look at user namespace for third-party sub-classes |
pretty |
prettify the output as |
getClassesInheriting("vrule_integer")getClassesInheriting("vrule_integer")
get the list of validation classes, ie classes extending vrule_abstract super class, including classes eventually defined outside vrule. In case the latter is on the search path, the list of validation classes will be cached for optimized used by vrule encoder/decoder.
getVruleClasses()getVruleClasses()
Emmanuel Blondel, [email protected]
getVruleClasses()getVruleClasses()
getVruleOption
getVruleOption(opt)getVruleOption(opt)
opt |
an option name |
the value for that option
setVruleOptions
setVruleOptions(...)setVruleOptions(...)
... |
options |
Provides tools to validate data based on business validation rules.
Maintainer: Emmanuel Blondel [email protected] (ORCID)
Authors:
Alexandre Bennici [email protected] (ORCID)
Useful links:
Report bugs at https://github.com/fdiwg/vrule/issues
Abstract validation rule
Abstract validation rule
new()
Initializes an abstract validation rule
vrule_abstract$new(..., type = c("ERROR", "WARNING"))...args
typethe type of rule either ERROR or WARNING
validate()
Abstract method to validate data
vrule_abstract$validate(value, ...)
valuevalue
...any other args
a validation report, object of class vrule_report
getType()
Get validation type
vrule_abstract$getType()
ERROR or WARNING
getCategory()
Get validation rule category
vrule_abstract$getCategory()
the validation rule category
getName()
Get validation rule name
vrule_abstract$getName()
the validation rule name
clone()
The objects of this class are cloneable with this method.
vrule_abstract$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_abstract_complex
vrule_abstract_complex
vrule::vrule_abstract -> vrule_abstract_complex
new()
Initializes an abstract complex validation rule
vrule_abstract_complex$new(...)
...args
validate()
Abstract method to validate data
vrule_abstract_complex$validate(value, ...)
valuevalue
...any other args
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_abstract_complex$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_abstract_simple
vrule_abstract_simple
vrule::vrule_abstract -> vrule_abstract_simple
new()
Initializes an abstract simple validation rule
vrule_abstract_simple$new(...)
...args
validate()
Abstract method to validate data
vrule_abstract_simple$validate(value, ...)
valuevalue
...any other args
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_abstract_simple$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_character
vrule_character
vrule::vrule_abstract -> vrule::vrule_abstract_simple -> vrule::vrule_datatype -> vrule_character
new()
Initializes a character data validation rule
vrule_character$new(na_allowed = FALSE, ...)
na_allowedis NA allowed?
...any other arg
validate()
Method to validate data
vrule_character$validate(value, ...)
valuevalue
...any other args
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_character$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_codelist
vrule_codelist
vrule::vrule_abstract -> vrule::vrule_abstract_simple -> vrule_codelist
ref_data_urlref data url
ref_dataref data
ref_data_columnref data column
ref_data_column_altref data alternate column
ref_meta_urlref metadata url
ref_metaref metadata
allow_labelsallow labels?
new()
Initializes a codelist validation rule
vrule_codelist$new( ref_data_url = NULL, ref_data_column = "code", ref_data_column_alt = "label", allow_labels = FALSE, ref_meta_url = NULL, ... )
ref_data_urlref data url
ref_data_columnref data column
ref_data_column_altref data alternate column
allow_labelsAllow labels?
ref_meta_urlref metadata url
...any other arg
validate()
Validates value with a codelist validation rule
vrule_codelist$validate(value, ...)
valuevalue
...any other args
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_codelist$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_cross_column
vrule_cross_column
vrule::vrule_abstract -> vrule::vrule_abstract_complex -> vrule_cross_column
operatoroperator
exprexpr
new()
Initializes a cross-column check validation rule
vrule_cross_column$new(operator, expr, ...)
operatoroperator
exprexpr
...any other arg
validate()
Abstract method to validate data
vrule_cross_column$validate(value, row)
valuevalue
rowrow
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_cross_column$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_datatype
vrule_datatype
vrule::vrule_abstract -> vrule::vrule_abstract_simple -> vrule_datatype
datatypedata type
na_allowedis NA allowed?
new()
Initializes a data type validation rule
vrule_datatype$new(datatype, na_allowed = FALSE, ...)
datatypedata type
na_allowedis NA allowed?
...any other arg
validate()
Abstract method to validate data
vrule_datatype$validate(value, ...)
valuevalue
...any other args
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_datatype$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_date
vrule_date
vrule::vrule_abstract -> vrule::vrule_abstract_simple -> vrule::vrule_datatype -> vrule::vrule_character -> vrule_date
new()
Initializes a date validation rule
vrule_date$new(na_allowed = FALSE, ...)
na_allowedTRUE if NA values are allowed, FALSE otherwise
...any other arg
validate()
Validates a date
vrule_date$validate(value, ...)
valuevalue
...any other args
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_date$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_date_max
vrule_date_max
vrule_date_max
vrule::vrule_abstract -> vrule::vrule_operator_binary -> vrule::vrule_operator_relational -> vrule_date_max
new()
Initializes a date max validation rule
vrule_date_max$new(maxValue, ...)
maxValuemax value
...any other arg
validate()
Validates data based on a max date threshold
vrule_date_max$validate(value, ...)
valuevalue
...any other args
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_date_max$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_date_min
vrule_date_min
vrule_date_min
vrule::vrule_abstract -> vrule::vrule_operator_binary -> vrule::vrule_operator_relational -> vrule_date_min
new()
Initializes a date min validation rule
vrule_date_min$new(minValue, ...)
minValuemin value
...any other arg
validate()
Validates data based on a min date threshold
vrule_date_min$validate(value, ...)
valuevalue
...any other args
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_date_min$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_date_range
vrule_date_range
vrule_date_range
vrule::vrule_abstract -> vrule::vrule_abstract_simple -> vrule_date_range
minValuemin value
maxValuemax value
new()
Initializes a range validation rule
vrule_date_range$new(minValue, maxValue, ...)
minValuemin value
maxValuemax value
...any other arg
validate()
Validates data based on a date range
vrule_date_range$validate(value, ...)
valuevalue
...any other args
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_date_range$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_date_threshold
vrule_date_threshold
vrule_date_threshold
vrule::vrule_abstract -> vrule::vrule_operator_binary -> vrule::vrule_operator_relational -> vrule_date_threshold
new()
Initializes a date threshold validation rule
vrule_date_threshold$new(operator, threshold, ...)
operatoroperator
thresholdthreshold
...any other arg
validate()
Validates data based on a date threshold
vrule_date_threshold$validate(value, ...)
valuevalue
...any other args
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_date_threshold$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_double
vrule_double
vrule::vrule_abstract -> vrule::vrule_abstract_simple -> vrule::vrule_datatype -> vrule_double
new()
Initializes a double data validation rule
vrule_double$new(na_allowed = FALSE, ...)
na_allowedis NA allowed?
...any other arg
validate()
Method to validate data
vrule_double$validate(value, ...)
valuevalue
...any other args
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_double$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_if
vrule_if
vrule::vrule_abstract -> vrule::vrule_abstract_complex -> vrule_if
if_conditionif expression
then_applylist of expressions to apply if condition is fulfilled
else_applylist of expressions to apply if condition is not fulfilled
new()
Initializes a conditionnal validation rule
vrule_if$new(if_condition, then_apply = list(), else_apply = list(), ...)
if_conditionif condition
then_applylist of expressions to apply if condition is fulfilled
else_applylist of expressions to apply if condition is not fulfilled
...any other arg
validate()
Abstract method to validate data
vrule_if$validate(value, row)
valuevalue
rowrow
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_if$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_integer
vrule_integer
vrule::vrule_abstract -> vrule::vrule_abstract_simple -> vrule::vrule_datatype -> vrule_integer
new()
Initializes a integer data validation rule
vrule_integer$new(na_allowed = FALSE, ...)
na_allowedis NA allowed?
...any other arg
validate()
Method to validate data
vrule_integer$validate(value, ...)
valuevalue
...any other args
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_integer$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_logical
vrule_logical
vrule::vrule_abstract -> vrule::vrule_abstract_simple -> vrule::vrule_datatype -> vrule_logical
new()
Initializes a logical data validation rule
vrule_logical$new(na_allowed = FALSE, ...)
na_allowedis NA allowed?
...any other arg
validate()
Method to validate data
vrule_logical$validate(value, ...)
valuevalue
...any other args
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_logical$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_mapping
vrule_mapping
vrule::vrule_abstract -> vrule::vrule_abstract_complex -> vrule_mapping
ref_data_urlref data url
ref_dataref data
ref_source_termref source term
ref_target_termref target term
data_target_termdata target term
ref_meta_urlref meta url
ref_metaref meta
new()
Initializes a mapping-based validation rule
vrule_mapping$new( ref_data_url = NULL, ref_source_term = NULL, ref_target_term = NULL, data_target_term = NULL, ref_meta_url = NULL, ... )
ref_data_urlref data url
ref_source_termref source term
ref_target_termref target term
data_target_termdata target term
ref_meta_urlref metadata url
...any other arg
validate()
Abstract method to validate data
vrule_mapping$validate(value, row)
valuevalue
rowrow
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_mapping$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_max
vrule_max
vrule_max
vrule::vrule_abstract -> vrule::vrule_operator_binary -> vrule::vrule_operator_relational -> vrule_max
new()
Initializes a max threshold validation rule
vrule_max$new(maxValue, ...)
maxValuemax value
...any other arg
validate()
Validates data based on a max threshold
vrule_max$validate(value, ...)
valuevalue
...any other args
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_max$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_min
vrule_min
vrule_min
vrule::vrule_abstract -> vrule::vrule_operator_binary -> vrule::vrule_operator_relational -> vrule_min
new()
Initializes a min threshold validation rule
vrule_min$new(minValue, ...)
minValuemin value
...any other arg
validate()
Validates data based on a min threshold
vrule_min$validate(value, ...)
valuevalue
...any other args
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_min$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_numeric
vrule_numeric
vrule::vrule_abstract -> vrule::vrule_abstract_simple -> vrule::vrule_datatype -> vrule_numeric
new()
Initializes a numeric data validation rule
vrule_numeric$new(na_allowed = FALSE, ...)
na_allowedis NA allowed?
...any other arg
validate()
Method to validate data
vrule_numeric$validate(value, ...)
valuevalue
...any other args
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_numeric$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_operator_and
vrule_operator_and
vrule::vrule_abstract -> vrule::vrule_operator_binary -> vrule::vrule_operator_logical -> vrule_operator_and
new()
Initializes a logical AND operator validation rule
vrule_operator_and$new(...)
...any other arg
validate()
Method to validate data
vrule_operator_and$validate(value, row)
valuevalue
rowrow
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_operator_and$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_operator_binary
vrule_operator_binary
vrule::vrule_abstract -> vrule_operator_binary
operatoroperator
exprexpr
new()
Initializes a binary operator validation rule
vrule_operator_binary$new(operator, expr, ...)
operatoroperator
exprexpr
...any other arg
validate()
Method to validate data
vrule_operator_binary$validate(value, ...)
valuevalue
...any other arg
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_operator_binary$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_operator_logical
vrule_operator_logical
vrule::vrule_abstract -> vrule::vrule_operator_binary -> vrule_operator_logical
operator_funoperator function
rulesrules
new()
Initializes a logical operator validation rule
vrule_operator_logical$new(operator, ...)
operatoroperator
...any other arg
validate()
Method to validate data
vrule_operator_logical$validate(value, row)
valuevalue
rowrow
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_operator_logical$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_operator_or
vrule_operator_or
vrule::vrule_abstract -> vrule::vrule_operator_binary -> vrule::vrule_operator_logical -> vrule_operator_or
new()
Initializes a logical OR operator validation rule
vrule_operator_or$new(...)
...any other arg
validate()
Method to validate data
vrule_operator_or$validate(value, row)
valuevalue
rowrow
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_operator_or$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_operator_relational
vrule_operator_relational
vrule_operator_relational
vrule::vrule_abstract -> vrule::vrule_operator_binary -> vrule_operator_relational
new()
Initializes a operator relational validation rule
vrule_operator_relational$new(operator, expr, ...)
operatoroperator
exprexpr
...any other arg
validate()
Abstract method to validate data
vrule_operator_relational$validate(value, ...)
valuevalue
...any other args
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_operator_relational$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_range
vrule_range
vrule_range
vrule::vrule_abstract -> vrule::vrule_abstract_simple -> vrule_range
minValuemin value
maxValuemax value
new()
Initializes a range validation rule
vrule_range$new(minValue, maxValue, ...)
minValuemin value
maxValuemax value
...any other arg
validate()
Validates data based on a range
vrule_range$validate(value, ...)
valuevalue
...any other args
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_range$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_raw_codelist
vrule_raw_codelist
vrule::vrule_abstract -> vrule::vrule_abstract_simple -> vrule_raw_codelist
ref_valuesref values
new()
Initializes a raw codelist validation rule
vrule_raw_codelist$new(ref_values = NULL, ...)
ref_valuesthe raw codelists values
...any other arg
validate()
Validates value with a raw codelist validation rule
vrule_raw_codelist$validate(value, ...)
valuevalue
...any other args
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_raw_codelist$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_report
vrule_report
validvalid
reportreport
new()
Initializes a validation report
vrule_report$new(valid = NULL, report = NULL)
validTRUE or FALSE
reportreport
clone()
The objects of this class are cloneable with this method.
vrule_report$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_threshold
vrule_threshold
vrule_threshold
vrule::vrule_abstract -> vrule::vrule_operator_binary -> vrule::vrule_operator_relational -> vrule_threshold
new()
Initializes a threshold validation rule
vrule_threshold$new(operator, threshold, ...)
operatoroperator
thresholdthreshold
...any other arg
validate()
Validates data based on a threshold
vrule_threshold$validate(value, ...)
valuevalue
...any other args
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_threshold$clone(deep = FALSE)
deepWhether to make a deep clone.
vrule_year
vrule_year
vrule::vrule_abstract -> vrule::vrule_abstract_simple -> vrule::vrule_datatype -> vrule::vrule_integer -> vrule_year
new()
Initializes a year validation rule
vrule_year$new(na_allowed = FALSE, ...)
na_allowedTRUE if NA values are allowed, FALSE otherwise
...any other arg
validate()
Validates a year
vrule_year$validate(value, ...)
valuevalue
...any other args
a validation report, object of class vrule_report
clone()
The objects of this class are cloneable with this method.
vrule_year$clone(deep = FALSE)
deepWhether to make a deep clone.