{"id":6854,"date":"2022-12-20T19:33:44","date_gmt":"2022-12-20T22:33:44","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/moosemetatypeconstraint-man3\/"},"modified":"2022-12-20T19:33:44","modified_gmt":"2022-12-20T22:33:44","slug":"moosemetatypeconstraint-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/moosemetatypeconstraint-man3\/","title":{"rendered":"Moose::Meta::TypeConstraint (man3)"},"content":{"rendered":"<h1 align=\"center\">Moose::Meta::TypeConstraint<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#VERSION\">VERSION<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#INHERITANCE\">INHERITANCE<\/a><br \/> <a href=\"#METHODS\">METHODS<\/a><br \/> <a href=\"#BUGS\">BUGS<\/a><br \/> <a href=\"#AUTHORS\">AUTHORS<\/a><br \/> <a href=\"#COPYRIGHT AND LICENSE\">COPYRIGHT AND LICENSE<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Moose::Meta::TypeConstraint \u2212 The Moose Type Constraint metaclass<\/p>\n<h2>VERSION <a name=\"VERSION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">version 2.2014<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This class represents a single type constraint. Moose\u2019s 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.<\/p>\n<h2>INHERITANCE <a name=\"INHERITANCE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">&#8220;Moose::Meta::TypeConstraint&#8221; is a subclass of Class::MOP::Object.<\/p>\n<h2>METHODS <a name=\"METHODS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Moose::Meta::TypeConstraint\u2212>new(%options)<\/b> <br \/> This creates a new type constraint based on the provided %options:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"6%\">\n<p>name<\/p>\n<\/td>\n<td width=\"77%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%; margin-top: 1em\">The constraint name. If a name is not provided, it will be set to &#8220;__ANON__&#8221;.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"9%\">\n<p style=\"margin-top: 1em\">parent<\/p>\n<\/td>\n<td width=\"74%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%; margin-top: 1em\">A &#8220;Moose::Meta::TypeConstraint&#8221; object which is the parent type for the type being created. This is optional.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"15%\">\n<p style=\"margin-top: 1em\">constraint<\/p>\n<\/td>\n<td width=\"68%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%; margin-top: 1em\">This is the subroutine reference that implements the actual constraint check. This defaults to a subroutine which always returns true.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"11%\">\n<p style=\"margin-top: 1em\">message<\/p>\n<\/td>\n<td width=\"72%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%; margin-top: 1em\">A subroutine reference which is used to generate an error message when the constraint fails. This is optional.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"12%\">\n<p style=\"margin-top: 1em\">coercion<\/p>\n<\/td>\n<td width=\"71%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%; margin-top: 1em\">A Moose::Meta::TypeCoercion object representing the coercions to the type. This is optional.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"11%\">\n<p style=\"margin-top: 1em\">inlined<\/p>\n<\/td>\n<td width=\"72%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%; margin-top: 1em\">A subroutine which returns a string suitable for inlining this type constraint. It will be called as a method on the type constraint object, and will receive a single additional parameter, a variable name to be tested (usually &#8220;$_&#8221; or &#8220;$_[0]&#8221;.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">This is optional.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"28%\">\n<p style=\"margin-top: 1em\">inline_environment<\/p>\n<\/td>\n<td width=\"55%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%; margin-top: 1em\">A hash reference of variables to close over. The keys are variables names, and the values are <i>references<\/i> to the variables.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>$constraint\u2212>equals($type_name_or_object)<\/b> <br \/> Returns true if the supplied name or type object is the same as the current type.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>$constraint\u2212>is_subtype_of($type_name_or_object)<\/b> <br \/> Returns true if the supplied name or type object is a parent of the current type.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>$constraint\u2212>is_a_type_of($type_name_or_object)<\/b> <br \/> 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 &#8220;equals&#8221; and &#8220;is_subtype_of&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>$constraint\u2212>coerce($value)<\/b> <br \/> This will attempt to coerce the value to the type. If the type does not have any defined coercions this will throw an error.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If no coercion can produce a value matching $constraint, the original value is returned.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>$constraint\u2212>assert_coerce($value)<\/b> <br \/> This method behaves just like &#8220;coerce&#8221;, but if the result is not valid according to $constraint, an error is thrown.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>$constraint\u2212>check($value)<\/b> <br \/> Returns true if the given value passes the constraint for the type.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>$constraint\u2212>validate($value)<\/b> <br \/> This is similar to &#8220;check&#8221;. However, if the type <i>is valid<\/i> then the method returns an explicit &#8220;undef&#8221;. If the type is not valid, we call &#8220;$self\u2212>get_message($value)&#8221; internally to generate an error message.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>$constraint\u2212>assert_valid($value)<\/b> <br \/> Like &#8220;check&#8221; and &#8220;validate&#8221;, 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 &#8220;$self\u2212>get_message($value)&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>$constraint\u2212>name<\/b> <br \/> Returns the type\u2019s name, as provided to the constructor.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>$constraint\u2212>parent<\/b> <br \/> Returns the type\u2019s parent, as provided to the constructor, if any.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>$constraint\u2212>has_parent<\/b> <br \/> Returns true if the type has a parent type.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>$constraint\u2212>parents<\/b> <br \/> Returns all of the types parents as an list of type constraint objects.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>$constraint\u2212>constraint<\/b> <br \/> Returns the type\u2019s constraint, as provided to the constructor.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>$constraint\u2212>get_message($value)<\/b> <br \/> This generates a method for the given value. If the type does not have an explicit message, we generate a default message.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>$constraint\u2212>has_message<\/b> <br \/> Returns true if the type has a message.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>$constraint\u2212>message<\/b> <br \/> Returns the type\u2019s message as a subroutine reference.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>$constraint\u2212>coercion<\/b> <br \/> Returns the type\u2019s Moose::Meta::TypeCoercion object, if one exists.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>$constraint\u2212>has_coercion<\/b> <br \/> Returns true if the type has a coercion.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>$constraint\u2212>can_be_inlined<\/b> <br \/> Returns true if this type constraint can be inlined. A type constraint which subtypes an inlinable constraint and does not add an additional constraint &#8220;inherits&#8221; its parent type\u2019s inlining.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>$constraint\u2212>create_child_type(%options)<\/b> <br \/> This returns a new type constraint of the same class using the provided %options. The &#8220;parent&#8221; option will be the current type.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This method exists so that subclasses of this class can override this behavior and change how child types are created.<\/p>\n<h2>BUGS <a name=\"BUGS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">See &#8221; <small>BUGS&#8221;<\/small> in Moose for details on reporting bugs.<\/p>\n<h2>AUTHORS <a name=\"AUTHORS\"><\/a> <\/h2>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"83%\">\n<p style=\"margin-top: 1em\">Stevan Little <stevan@cpan.org><\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"83%\">\n<p>Dave Rolsky <autarch@urth.org><\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"83%\">\n<p>Jesse Luehrs <doy@cpan.org><\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"83%\">\n<p>Shawn M Moore <sartak@cpan.org><\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"83%\">\n<p>\u00d7\u00d7\u00d7\u00d7 \u00d7\u00a7\u00d7\u00d7\u2019\u00d7\u00d7 (Yuval Kogman) <nothingmuch@woobling.org><\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"83%\">\n<p>Karen Etheridge <ether@cpan.org><\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"83%\">\n<p>Florian Ragwitz <rafl@debian.org><\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"83%\">\n<p>Hans Dieter Pearcey <hdp@cpan.org><\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"83%\">\n<p>Chris Prather <chris@prather.org><\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"83%\">\n<p>Matt S Trout <mstrout@cpan.org><\/p>\n<\/td>\n<\/tr>\n<\/table>\n<h2>COPYRIGHT AND LICENSE <a name=\"COPYRIGHT AND LICENSE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This software is copyright (c) 2006 by Infinity Interactive, Inc.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This is free software; you can redistribute it and\/or modify it under the same terms as the Perl 5 programming language system itself.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  Moose::Meta::TypeConstraint \u2212 The Moose Type Constraint metaclass <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3007,3219],"class_list":["post-6854","post","type-post","status-publish","format-standard","hentry","category-sin-categoria","tag-man3","tag-moosemetatypeconstraint"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6854","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=6854"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6854\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=6854"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=6854"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=6854"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}