Skip to contents

See new_constraints for constructor function.

Value

Initialized instance

Formatted characters

Either TRUE if passed or a collection of assertion failures (or errors)

TRUE if valid, otherwise returns the error message

A list of constraint data that can be passed into $restore method

RAVEVariableConstraints instance

Public fields

type

character(1), type indicator

Active bindings

n_validators

Number of validation functions

isRAVEVariableConstraints

always true

generator

class definition

Methods


Method new()

Constructor method

Usage

RAVEVariableConstraints$new(type = "UnboundedConstraint", assertions = NULL)

Arguments

type

type of the variable; default is 'UnboundedConstraint'

assertions

named list of the constraint parameters. The names of assertions will be used to indicate the constraint type, and the values are the constraint parameters.


Method format()

Format method

Usage

RAVEVariableConstraints$format(...)

Arguments

...

ignored


Method assert()

Validate the constraints

Usage

RAVEVariableConstraints$assert(
  x,
  .var.name = checkmate::vname(x),
  on_error = c("error", "warning", "message", "muffle"),
  env = parent.frame(),
  data = NULL
)

Arguments

x

value to validate

.var.name

descriptive name of x

on_error

error handler, default is 'error': stop on first validation error

env

environment of validation (used when assertions are expressions)

data

named list of additional data to be used for evaluation if constraint is an expression


Method check()

Check if the value is valid with no error raised

Usage

RAVEVariableConstraints$check(x, env = parent.frame(), data = NULL)

Arguments

x

valid to be validated

env

environment to evaluate validation expressions

data

named list of additional data to be used for evaluation if constraint is an expression


Method store()

Convert constraint to atomic list, used for serializing

Usage

RAVEVariableConstraints$store(...)

Arguments

...

ignored


Method restore()

Restores from atomic list generated by $store()

Usage

RAVEVariableConstraints$restore(x, ...)

Arguments

x

atomic list

...

ignored


Method clone()

The objects of this class are cloneable with this method.

Usage

RAVEVariableConstraints$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.