Type::API::Constraint::Coercible - allows values failing the type constraint to be converted to another value that passes
Implementations of Type::API::Constraint::Coercible MUST also implement Type::API::Constraint.
Implementations MUST provide the following methods:
$constraint->has_coercion
Returns a boolean indicating whether a coercion is available for this type constraint.
$constraint->coerce($value)
Attempts to coerce the value into a value that would pass the type constraint; this method returns the new value. This method offers no guarantee that the returned value passes the constraint; that must be checked with check.
check
Implementations MAY advertise that they support this interface by returning true for $constraint->DOES("Type::API::Constraint::Coercible").
$constraint->DOES("Type::API::Constraint::Coercible")
The following CPAN classes are known to implement Type::API::Constraint::Coercible:
Moose::Meta::TypeConstraint (and its subclasses)
MooseX::Meta::TypeDecorator
Mouse::Meta::TypeConstraint
MouseX::Meta::TypeDecorator
Specio::Constraint::Simple (and several other classes in the Specio distribution)
Type::Tiny (and its subclasses)
Some tools can make use of objects implementing Type::API::Constraint::Coercible:
Smart::Args
Type::Tie
Others, such as Moose and Mouse require type constraints that implement a superset of this functionality.
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::API, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Type::API
CPAN shell
perl -MCPAN -e shell install Type::API
For more information on module installation, please visit the detailed CPAN module installation guide.