Class-Tiny icon indicating copy to clipboard operation
Class-Tiny copied to clipboard

Applying constraints using custom accessors?

Open cxw42 opened this issue 6 years ago • 2 comments

I am enjoying using Class::Tiny! I would like to add type constraints to my setters to enforce preconditions early. It is easy, but repetitive, to copy the sample accessor from the C::T POD and add a constraint check. Is there already a module or C::T feature that does that? I looked on CPAN but couldn't find one. For example, Class::Tiny::Antlers does not provide isa.

If there is an existing way or module, would you be willing to update the C::T POD to reference it? If not, I will write Class::Tiny::ConstrainedAccessor and then send a PR for the POD. Thanks for considering this question and request!

cxw42 avatar Mar 06 '19 13:03 cxw42

In progress at https://github.com/cxw42/Class-Tiny-ConstrainedAccessor

cxw42 avatar Mar 12 '19 14:03 cxw42

Thanks

xdg avatar Mar 12 '19 15:03 xdg