Could a NewOption be added to configure a custom validation function to run after the struct is instantiated?
This would allow us to then run https://docs.rs/crate/validator/0.20.0 inside of new
A common pattern is to enforce private access to struct fields so that new enforces non-empty string fields or collections.
Although it's possible to make new private and then write your own new_valid that calls new, the problem is you then have to add all of the arguments yourself to new_valid, which sort of is the intent of using derive-new to begin with.
Could a
NewOptionbe added to configure a custom validation function to run after the struct is instantiated?This would allow us to then run https://docs.rs/crate/validator/0.20.0 inside of
newA common pattern is to enforce private access to struct fields so that
newenforces non-empty string fields or collections.Although it's possible to make
newprivate and then write your ownnew_validthat callsnew, the problem is you then have to add all of the arguments yourself tonew_valid, which sort of is the intent of usingderive-newto begin with.