Moose::Meta::TypeConstraint - The Moose Type Constraint metaclass
This class represents a single type constraint. Moose's built-in type constraints, as well as constraints you define, are all stored in a Moose::Meta::TypeConstraint::Registry object as objects of this class.
Moose::Meta::TypeConstraint is a subclass of Class::MOP::Object.
This creates a new type constraint based on the provided
The constraint name. If a name is not provided, it will be set to "__ANON__".
Moose::Meta::TypeConstraint object which is the parent type for the type being created.
This is optional.
This is the subroutine reference that implements the actual constraint check. This defaults to a subroutine which always returns true.
A subroutine reference which is used to generate an error message when the constraint fails. This is optional.
A Moose::Meta::TypeCoercion object representing the coercions to the type. This is optional.
This is a variant of the
constraint parameter that is somehow optimized.
this means incorporating both the type's constraint and all of its parents' constraints into a single subroutine reference.
Returns true if the supplied name or type object is the same as the current type.
Returns true if the supplied name or type object is a parent of the current type.
Returns true if the given type is the same as the current type,
or is a parent of the current type.
This is a shortcut for checking
This will attempt to coerce the value to the type. If the type does not have any defined coercions this will throw an error.
If no coercion can produce a value matching
the original value is returned.
This method behaves just like
but if the result is not valid according to
an error is thrown.
Returns true if the given value passes the constraint for the type.
This is similar to
if the type is valid then the method returns an explicit
If the type is not valid,
$self->get_message($value) internally to generate an error message.
this method checks whether
$value is valid under the constraint.
If it is,
it will return true.
If it is not,
an exception will be thrown with the results of
Returns the type's name, as provided to the constructor.
Returns the type's parent, as provided to the constructor, if any.
Returns true if the type has a parent type.
A synonym for
This is useful for polymorphism with types that can have more than one parent.
Returns the type's constraint, as provided to the constructor.
This generates a method for the given value. If the type does not have an explicit message, we generate a default message.
Returns true if the type has a message.
Returns the type's message as a subroutine reference.
Returns the type's Moose::Meta::TypeCoercion object, if one exists.
Returns true if the type has a coercion.
Returns the type's hand optimized constraint,
as provided to the constructor via the
Returns true if the type has an optimized constraint.
This returns a new type constraint of the same class using the provided
parent option will be the current type.
This method exists so that subclasses of this class can override this behavior and change how child types are created.
See "BUGS" in Moose for details on reporting bugs.
Stevan Little <email@example.com>
Copyright 2006-2010 by Infinity Interactive, Inc.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.