File Coverage

blib/lib/WWW/LogicBoxes/Types.pm
Criterion Covered Total %
statement 24 24 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod n/a
total 32 32 100.0


line stmt bran cond sub pod time code
1             package WWW::LogicBoxes::Types;
2              
3 68     68   524 use strict;
  68         162  
  68         2213  
4 68     68   382 use warnings;
  68         144  
  68         2264  
5              
6 68     68   36672 use Data::Validate::Domain qw( is_domain );
  68         954369  
  68         4583  
7 68     68   38595 use Data::Validate::Email qw( is_email );
  68         2028901  
  68         5108  
8 68     68   41586 use Data::Validate::IP qw( is_ipv4 is_ipv6 );
  68         2332468  
  68         6836  
9 68     68   39749 use Data::Validate::URI qw( is_uri );
  68         62431  
  68         7660  
10              
11             our $VERSION = '1.11.0'; # VERSION
12             # ABSTRACT: WWW::LogicBoxes Moose Type Library
13              
14 68         1075 use MooseX::Types -declare => [qw(
15             ArrayRef
16             Bool
17             HashRef
18             Int
19             Str
20             Strs
21              
22             ContactType
23             CPR
24             CPRIndividual
25             CPRNonIndividual
26             DateTime
27             DomainName
28             DomainNames
29             DomainStatus
30             EmailAddress
31             InvoiceOption
32             IP
33             IPs
34             IPv4
35             IPv4s
36             IPv6
37             IPv6s
38             IRTPFOAStatus
39             IRTPStatus
40             Language
41             NexusCategory
42             NexusPurpose
43             NumberPhone
44             Password
45             PhoneNumber
46             ResponseType
47             URI
48             VerificationStatus
49              
50             Contact
51             Customer
52             Domain
53             DomainAvailability
54             DomainAvailabilities
55             DomainRegistration
56             DomainTransfer
57             IRTPDetail
58             PrivateNameServer
59             PrivateNameServers
60 68     68   39273 )];
  68         2866971  
61              
62             use MooseX::Types::Moose
63 68         920 ArrayRef => { -as => 'MooseArrayRef' },
64             Bool => { -as => 'MooseBool' },
65             HashRef => { -as => 'MooseHashRef' },
66             Int => { -as => 'MooseInt' },
67 68     68   1900773 Str => { -as => 'MooseStr' };
  68         1218935  
68              
69             subtype ArrayRef, as MooseArrayRef;
70             subtype Bool, as MooseBool;
71             subtype HashRef, as MooseHashRef;
72             subtype Int, as MooseInt;
73             subtype Str, as MooseStr;
74              
75             subtype Strs, as ArrayRef[Str];
76              
77             enum ContactType, [qw(
78             Contact
79             AtContact
80             CaContact
81             CnContact
82             CoContact
83             CoopContact
84             DeContact
85             EsContact
86             EuContact
87             NlContact
88             RuContact
89             UkContact
90             )];
91             enum CPRIndividual, [qw( ABO CCT LGR RES )];
92             enum CPRNonIndividual, [qw( ASS CCO EDU GOV HOP INB LAM MAJ OMK PLT PRT TDM TRD TRS )];
93             subtype CPR, as CPRIndividual | CPRNonIndividual;
94              
95             enum DomainStatus, [ 'InActive', 'Active', 'Suspended', 'Pending Delete Restorable',
96             'QueuedForDeletion', 'Deleted', 'Archived' ];
97             enum InvoiceOption, [qw( NoInvoice PayInvoice KeepInvoice )];
98             enum IRTPFOAStatus, [qw( PENDING APPROVED DISAPPROVED )];
99             enum IRTPStatus, [qw( PENDING REVOKED EXPIRED FAILED APPROVED SUCCESS REMOTE_FAILURE )];
100             enum Language, [qw( en )];
101             enum NexusCategory, [qw( C11 C12 C21 C31 C32 )];
102             enum NexusPurpose, [qw( P1 P2 P3 P4 P5 )];
103             enum ResponseType, [qw( xml json xml_simple )];
104             enum VerificationStatus, [qw( Verified Pending Suspended NA )];
105              
106             class_type Contact, { class => 'WWW::LogicBoxes::Contact' };
107             coerce Contact, from HashRef, via {
108             exists $_->{nexus_purpose} and return WWW::LogicBoxes::Contact::US->new( $_ );
109             return WWW::LogicBoxes::Contact->new( $_ );
110             };
111              
112             class_type Customer, { class => 'WWW::LogicBoxes::Customer' };
113             coerce Customer, from HashRef,
114             via { WWW::LogicBoxes::Customer->new( $_ ) };
115              
116             class_type DateTime, { class => 'DateTime' };
117              
118             class_type Domain, { class => 'WWW::LogicBoxes::Domain' };
119             coerce Domain, from HashRef,
120             via { WWW::LogicBoxes::Domain->new( $_ ) };
121              
122             class_type DomainAvailability, { class => 'WWW::LogicBoxes::DomainAvailability' };
123             subtype DomainAvailabilities, as ArrayRef[DomainAvailability];
124              
125             class_type DomainRegistration, { class => 'WWW::LogicBoxes::DomainRequest::Registration' };
126             coerce DomainRegistration, from HashRef,
127             via { WWW::LogicBoxes::DomainRequest::Registration->new( $_ ) };
128              
129             class_type DomainTransfer, { class => 'WWW::LogicBoxes::DomainRequest::Transfer' };
130             coerce DomainTransfer, from HashRef,
131             via { WWW::LogicBoxes::DomainRequest::Transfer->new( $_ ) };
132              
133             class_type IRTPDetail, { class => 'WWW::LogicBoxes::IRTPDetail' };
134              
135             class_type NumberPhone, { class => 'Number::Phone' };
136             class_type PhoneNumber, { class => 'WWW::LogicBoxes::PhoneNumber' };
137             coerce PhoneNumber, from Str,
138             via { WWW::LogicBoxes::PhoneNumber->new( $_ ) };
139             coerce PhoneNumber, from NumberPhone,
140             via { WWW::LogicBoxes::PhoneNumber->new( $_->format ) };
141              
142             class_type PrivateNameServer, { class => 'WWW::LogicBoxes::PrivateNameServer' };
143             coerce PrivateNameServer, from HashRef,
144             via { WWW::LogicBoxes::PrivateNameServer->new( $_ ) };
145             subtype PrivateNameServers, as ArrayRef[PrivateNameServer];
146              
147             subtype DomainName, as Str,
148             where { is_domain( $_ ) },
149             message { "$_ is not a valid domain" };
150             subtype DomainNames, as ArrayRef[DomainName];
151              
152             subtype EmailAddress, as Str,
153             where { is_email( $_ ) },
154             message { "$_ is not a valid email address" };
155              
156             subtype IPv4, as Str,
157             where { is_ipv4( $_ ) },
158             message { "$_ is not a valid ipv4 IP Address" };
159             subtype IPv4s, as ArrayRef[IPv4];
160              
161             subtype IPv6, as Str,
162             where { is_ipv6( $_ ) },
163             message { "$_ is not a valid ipv6 IP Address" };
164             subtype IPv6s, as ArrayRef[IPv6];
165              
166             subtype IP, as IPv4 | IPv6;
167             subtype IPs, as ArrayRef[IP];
168              
169             subtype Password, as Str,
170             where {(
171             $_ =~ m/([a-zA-Z0-9])+/ # Alphanumeric
172             && length($_) >= 8 && length($_) <= 15 # Between 8 and 15 Characters
173             )},
174             message { "$_ is not a valid password. It must be alphanumeric and between 8 and 15 characters" };
175              
176             subtype URI, as Str,
177             where { is_uri( $_ ) },
178             message { "$_ is not a valid URI" };
179              
180             1;
181              
182             __END__