1Moose::Meta::TypeConstrUasienrt:C:oUnntiroinb(u3t)ed PerMlooDsoec:u:mMeenttaa:t:iToynpeConstraint::Union(3)
2
3
4
6 Moose::Meta::TypeConstraint::Union - A union of Moose type constraints
7
9 version 2.2011
10
12 This metaclass represents a union of type constraints. A union takes
13 multiple type constraints, and is true if any one of its member
14 constraints is true.
15
17 "Moose::Meta::TypeConstraint::Union" is a subclass of
18 Moose::Meta::TypeConstraint.
19
21 Moose::Meta::TypeConstraint::Union->new(%options)
22 This creates a new class type constraint based on the given %options.
23
24 It takes the same options as its parent. It also requires an additional
25 option, "type_constraints". This is an array reference containing the
26 Moose::Meta::TypeConstraint objects that are the members of the union
27 type. The "name" option defaults to the names all of these member types
28 sorted and then joined by a pipe (|).
29
30 The constructor sets the implementation of the constraint so that is
31 simply calls "check" on the newly created object.
32
33 Finally, the constructor also makes sure that the object's "coercion"
34 attribute is a Moose::Meta::TypeCoercion::Union object.
35
36 $constraint->type_constraints
37 This returns the array reference of "type_constraints" provided to the
38 constructor.
39
40 $constraint->parent
41 This returns the nearest common ancestor of all the components of the
42 union.
43
44 $constraint->check($value)
45 $constraint->validate($value)
46 These two methods simply call the relevant method on each of the member
47 type constraints in the union. If any type accepts the value, the value
48 is valid.
49
50 With "validate" the error message returned includes all of the error
51 messages returned by the member type constraints.
52
53 $constraint->equals($type_name_or_object)
54 A type is considered equal if it is also a union type, and the two
55 unions have the same member types.
56
57 $constraint->find_type_for($value)
58 This returns the first member type constraint for which "check($value)"
59 is true, allowing you to determine which of the Union's member type
60 constraints a given value matches.
61
62 $constraint->is_a_type_of($type_name_or_object)
63 This returns true if all of the member type constraints return true for
64 the "is_a_type_of" method.
65
66 $constraint->is_subtype_of
67 This returns true if all of the member type constraints return true for
68 the "is_subtype_of" method.
69
70 $constraint->create_child_type(%options)
71 This returns a new Moose::Meta::TypeConstraint object with the type as
72 its parent.
73
75 See "BUGS" in Moose for details on reporting bugs.
76
78 · Stevan Little <stevan.little@iinteractive.com>
79
80 · Dave Rolsky <autarch@urth.org>
81
82 · Jesse Luehrs <doy@tozt.net>
83
84 · Shawn M Moore <code@sartak.org>
85
86 · יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
87
88 · Karen Etheridge <ether@cpan.org>
89
90 · Florian Ragwitz <rafl@debian.org>
91
92 · Hans Dieter Pearcey <hdp@weftsoar.net>
93
94 · Chris Prather <chris@prather.org>
95
96 · Matt S Trout <mst@shadowcat.co.uk>
97
99 This software is copyright (c) 2006 by Infinity Interactive, Inc.
100
101 This is free software; you can redistribute it and/or modify it under
102 the same terms as the Perl 5 programming language system itself.
103
104
105
106perl v5.28.1 2018-05-M1o6ose::Meta::TypeConstraint::Union(3)