3 ms·
If you planned on using objects, you can consider using Moo for roles to allow composition, and combining it with Types::Tiny for type validation. There's also
by muraiki 12y ago
If you planned on using objects, you can consider using Moo for roles to allow composition, and combining it with Types::Tiny for type validation. There's also Params::Validate for plain functions.
The validation is unfortunately at runtime, but at least you get a clear error instead of unanticipated behavior. Moo (and it's bigger parent, Moose) can really help you structure your application better using roles.
https://metacpan.org/pod/Moo https://metacpan.org/pod/Moo
https://metacpan.org/pod/Type::Tiny https://metacpan.org/pod/Type::Tiny
Edit: Don't use Params::Validate; kbenson's recommendation for Function::Parameters looks awesome!
- eCa 12y agoThere is also Kavorka[1] as an alternative to Function::Parameters, which can use Type::Tiny types in signatures. The next step after that is Moops[2]... [1] https://metacpan.org/pod/Kavorka https://metacpan.org/pod/Kavorka [2] https://metacpan.org/pod/Moops https://metacpan.org/pod/Moops