-
Notifications
You must be signed in to change notification settings - Fork 42
Closed
Description
My mental model is that properties are responsible for validating themselves (for the most part), but the class validator can check to make sure that the properties work with one another. However, a property with a setter breaks that model.
library(S7)
class_testing <- new_class(
name = "testing",
properties = list(
first = class_character,
second = new_property(
setter = function(self, value) {
# Do some things to prep value, then...
self@second <- value
self
}
)
),
validator = function(self) {
message("Validating the properties against one another")
}
)
testing <- class_testing()
#> Validating the properties against one another
testing@second <- "this does not trigger validation"
testing@first <- "this triggers validation"
#> Validating the properties against one anotherCreated on 2023-12-05 with reprex v2.0.2
Is this working as intended? Is there a way to trigger overall validation after a property that has a setter is updated?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels