NAME
Type::Standard - bundled set of built-in types for Type::Tiny
DESCRIPTION
Type::Tiny bundles a few types which seem to be useful.
Moose-like
The following types are similar to those described in Moose::Util::TypeConstraints.
Any
Item
Bool
Maybe[`a]
Undef
Defined
Value
Str
Num
Int
ClassName
RoleName
Ref[`a]
ScalarRef[`a]
ArrayRef[`a]
HashRef[`a]
CodeRef
RegexpRef
GlobRef
FileHandle
Object
Unlike Moose, Ref
is a parameterized type, allowing Scalar::Util::reftype checks, a la
Ref["HASH"] # hashrefs, including blessed hashrefs
Structured
OK, so I stole some ideas from MooseX::Types::Structured.
This module also exports a slurpy
function.
More
There are a couple of other types exported by this function:
Overload[`a]
-
With no parameters, checks that the value is an overloaded object. Can be given one or more string parameters, which are specific operations to check are overloaded. For example, the following checks for objects which overload addition and subtraction.
Overload["+", "-"]
StrMatch[`a]
-
A string that matches a regular exception:
declare "Distance", as StrMatch[ qr{^([0-9]+)\s*(mm|cm|m|km)$} ];
You can optionally provide a type constraint for the array of subexpressions:
declare "Distance", as StrMatch[ qr{^([0-9]+)\s*(.+)$}, Tuple[ Int, enum(DistanceUnit => [qw/ mm cm m km /]), ], ];
BUGS
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=Type-Tiny.
SEE ALSO
Type::Tiny, Type::Library, Type::Utils, Type::Coercion.
Moose::Util::TypeConstraints, Mouse::Util::TypeConstraints, MooseX::Types::Structured.
AUTHOR
Toby Inkster <tobyink@cpan.org>.
COPYRIGHT AND LICENCE
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.
DISCLAIMER OF WARRANTIES
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.