Skip to content

Validator not triggered when new_class derives from base class #495

@tschwarzl

Description

@tschwarzl

Related to #413

The validator is also not triggered when new_class derives from a base type as showcased in this example e.g.:

list_derived_class <- new_class(
  "list_derived_class",
  parent = class_list,
  validator = function(self) {
    if(length(self) > 0)
      "raising non-empty test error"
  }
)

x <- list_derived_class()
x[["A"]] = 1
x[["B"]] = 2

This is rather counter intuitive behavior when deriving from a class.

One suggestion would be that S7_base_class provided by e.g. class_list would overwrite the base setters installing a hook to trigger the validator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions