1Moose::Meta::TypeConstrUasienrt(C3o)ntributed Perl DocumMeonotsaet:i:oMneta::TypeConstraint(3)
2
3
4

NAME

6       Moose::Meta::TypeConstraint - The Moose Type Constraint metaclass
7

VERSION

9       version 2.2012
10

DESCRIPTION

12       This class represents a single type constraint. Moose's built-in type
13       constraints, as well as constraints you define, are all stored in a
14       Moose::Meta::TypeConstraint::Registry object as objects of this class.
15

INHERITANCE

17       "Moose::Meta::TypeConstraint" is a subclass of Class::MOP::Object.
18

METHODS

20   Moose::Meta::TypeConstraint->new(%options)
21       This creates a new type constraint based on the provided %options:
22
23       ·   name
24
25           The constraint name. If a name is not provided, it will be set to
26           "__ANON__".
27
28       ·   parent
29
30           A "Moose::Meta::TypeConstraint" object which is the parent type for
31           the type being created. This is optional.
32
33       ·   constraint
34
35           This is the subroutine reference that implements the actual
36           constraint check. This defaults to a subroutine which always
37           returns true.
38
39       ·   message
40
41           A subroutine reference which is used to generate an error message
42           when the constraint fails. This is optional.
43
44       ·   coercion
45
46           A Moose::Meta::TypeCoercion object representing the coercions to
47           the type. This is optional.
48
49       ·   inlined
50
51           A subroutine which returns a string suitable for inlining this type
52           constraint. It will be called as a method on the type constraint
53           object, and will receive a single additional parameter, a variable
54           name to be tested (usually "$_" or "$_[0]".
55
56           This is optional.
57
58       ·   inline_environment
59
60           A hash reference of variables to close over. The keys are variables
61           names, and the values are references to the variables.
62
63   $constraint->equals($type_name_or_object)
64       Returns true if the supplied name or type object is the same as the
65       current type.
66
67   $constraint->is_subtype_of($type_name_or_object)
68       Returns true if the supplied name or type object is a parent of the
69       current type.
70
71   $constraint->is_a_type_of($type_name_or_object)
72       Returns true if the given type is the same as the current type, or is a
73       parent of the current type. This is a shortcut for checking "equals"
74       and "is_subtype_of".
75
76   $constraint->coerce($value)
77       This will attempt to coerce the value to the type. If the type does not
78       have any defined coercions this will throw an error.
79
80       If no coercion can produce a value matching $constraint, the original
81       value is returned.
82
83   $constraint->assert_coerce($value)
84       This method behaves just like "coerce", but if the result is not valid
85       according to $constraint, an error is thrown.
86
87   $constraint->check($value)
88       Returns true if the given value passes the constraint for the type.
89
90   $constraint->validate($value)
91       This is similar to "check". However, if the type is valid then the
92       method returns an explicit "undef". If the type is not valid, we call
93       "$self->get_message($value)" internally to generate an error message.
94
95   $constraint->assert_valid($value)
96       Like "check" and "validate", this method checks whether $value is valid
97       under the constraint.  If it is, it will return true.  If it is not, an
98       exception will be thrown with the results of
99       "$self->get_message($value)".
100
101   $constraint->name
102       Returns the type's name, as provided to the constructor.
103
104   $constraint->parent
105       Returns the type's parent, as provided to the constructor, if any.
106
107   $constraint->has_parent
108       Returns true if the type has a parent type.
109
110   $constraint->parents
111       Returns all of the types parents as an list of type constraint objects.
112
113   $constraint->constraint
114       Returns the type's constraint, as provided to the constructor.
115
116   $constraint->get_message($value)
117       This generates a method for the given value. If the type does not have
118       an explicit message, we generate a default message.
119
120   $constraint->has_message
121       Returns true if the type has a message.
122
123   $constraint->message
124       Returns the type's message as a subroutine reference.
125
126   $constraint->coercion
127       Returns the type's Moose::Meta::TypeCoercion object, if one exists.
128
129   $constraint->has_coercion
130       Returns true if the type has a coercion.
131
132   $constraint->can_be_inlined
133       Returns true if this type constraint can be inlined. A type constraint
134       which subtypes an inlinable constraint and does not add an additional
135       constraint "inherits" its parent type's inlining.
136
137   $constraint->create_child_type(%options)
138       This returns a new type constraint of the same class using the provided
139       %options. The "parent" option will be the current type.
140
141       This method exists so that subclasses of this class can override this
142       behavior and change how child types are created.
143

BUGS

145       See "BUGS" in Moose for details on reporting bugs.
146

AUTHORS

148       ·   Stevan Little <stevan.little@iinteractive.com>
149
150       ·   Dave Rolsky <autarch@urth.org>
151
152       ·   Jesse Luehrs <doy@tozt.net>
153
154       ·   Shawn M Moore <code@sartak.org>
155
156       ·   יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
157
158       ·   Karen Etheridge <ether@cpan.org>
159
160       ·   Florian Ragwitz <rafl@debian.org>
161
162       ·   Hans Dieter Pearcey <hdp@weftsoar.net>
163
164       ·   Chris Prather <chris@prather.org>
165
166       ·   Matt S Trout <mst@shadowcat.co.uk>
167
169       This software is copyright (c) 2006 by Infinity Interactive, Inc.
170
171       This is free software; you can redistribute it and/or modify it under
172       the same terms as the Perl 5 programming language system itself.
173
174
175
176perl v5.30.1                      2020-01-30    Moose::Meta::TypeConstraint(3)
Impressum