Type::Tiny::Manual - an overview of Type::Tiny
Type::Tiny is a small class for writing type constraints, inspired by Moose's type constraint API. It has no non-core dependencies, and can be used with Moose, Mouse and Moo (or none of the above).
Type::Tiny is bundled with Type::Library a framework for organizing type constraints into collections.
Also bundled is Types::Standard, a Moose-inspired library of useful type constraints.
Type::Params is also provided, to allow very fast checking and coercion of function and method parameters.
Libraries - how to build a type library with Type::Tiny, Type::Library and Type::Utils
Coercions - adding coercions to type constraints
Using with Moose - how to use Type::Tiny and Type::Library with Moose
Using with Mouse - how to use Type::Tiny and Type::Library with Mouse
Using with Moo - how to use Type::Tiny and Type::Library with Moo
Using with Other OO Frameworks - how to use Type::Tiny and Type::Library with other OO frameworks
Type::Tiny and friends don't need to be used within an OO framework. See FreeMind::Node for an example that does not.
Processing arguments to subs - coerce and validate arguments to functions and methods.
Other modules using Type::Tiny in interesting ways: Type::Tie, Scalar::Does...
Type::Tiny is similar in aim to Specio. The major differences are that Type::Tiny is "tiny"; and Type::Tiny dispenses with the idea of a type registry and stringy access to type constraints.
Type::Tiny libraries expose a similar interface to MooseX::Types libraries. In most cases you should be able to rewrite a MooseX::Types library to use Type::Tiny pretty easily.
Type::Tiny is faster and supports coercions.
Scalar::Does is somewhat of a precursor to Type::Tiny, but has now been rewritten to use Type::Tiny internally.
It gives you a does($value, $type) function that is roughly equivalent to $type->check($value) except that $type may be one of a list of pre-defined strings (instead of a Type::Tiny type constraint); or may be a package name in which case it will be assumed to be a role and checked with $value->DOES($type).
does($value, $type)
$type->check($value)
$type
$value->DOES($type)
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=Type-Tiny.
IRC: support is available through in the #moose channel on irc.perl.org. If Type::Tiny discussion there becomes overwhelming (unlikely) then I'll move it to a separate channel.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2013 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
To install Type::Tiny, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Type::Tiny
CPAN shell
perl -MCPAN -e shell install Type::Tiny
For more information on module installation, please visit the detailed CPAN module installation guide.