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 another
Created 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?
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.
Created 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?