tidylab / decorators

Extend the behaviour of a function without explicitly modifying it
https://tidylab.github.io/decorators/
Other
12 stars 0 forks source link

Add validate_input decorator #3

Closed harell closed 3 years ago

harell commented 3 years ago
Car <- function(model = NA_character_, hp = NA_real_) return(
   data.frame(modek = model, hp = hp)
)

Car <- validate_input (Car)
car <- Car(model = 555, hp = 120) # fails because model is numeric rather than character 
harell commented 3 years ago

validate_input decorator