Class definition of 'RAVE' constrained variable
Source:R/class-variable-constraint.R
RAVEVariable.Rd
See new_constrained_variable
for constructor function.
Value
Formatted characters
Self instance
Self
Current value
TRUE
if valid, otherwise returns the error message
A list of constraint data that can be passed into
$restore
method
RAVEVariable
instance
Active bindings
constraints
instance of
RAVEVariableConstraints
, used to validate the inputisRAVEVariable
always true
type
constraint type
value
value of the variable
initialized
whether value is missing (value might not be valid)
generator
class definition
Methods
Method format()
Format method
Method use_constraints()
Set variable validation
Arguments
constraints
either a
character(1)
or aRAVEVariableConstraints
instance. Whenconstraints
is a string, the value will be thetype
of the constraint ( seenew_constraints
).i, ...
used when
constraints
is a string, either.i
is an expression, orlist(.i,...)
forms a list of control parameters; seeassertions
innew_constraints
.
Method set_value()
Set value
Usage
RAVEVariable$set_value(
x,
env = parent.frame(),
validate = TRUE,
on_error = NULL
)
Arguments
x
value of the variable
env
environment in which the validations will be evaluated
validate
whether to validate if
x
is legit; if set toTRUE
andx
is invalid, then the values will not be set.on_error
a function takes two arguments: the error instance and old value; the returned value will be used to re-validate. Default is
NULL
, which is identical to returning the old value and stop on error.
Method validate()
Check if the value is valid
Usage
RAVEVariable$validate(
env = parent.frame(),
on_error = c("error", "warning", "message", "muffle")
)
Method check()
Check if the value is valid with no error raised
Usage
RAVEVariable$check(env = parent.frame())
Method restore()
Restores from atomic list generated by $store()
Usage
RAVEVariable$restore(x, env = parent.frame(), ...)