File Coverage

blib/lib/Net/DRI/Data/Contact/US.pm
Criterion Covered Total %
statement 15 26 57.6
branch 0 12 0.0
condition 0 17 0.0
subroutine 5 6 83.3
pod 0 1 0.0
total 20 62 32.2


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, Handling of contact data for .US
2             ##
3             ## Copyright (c) 2006-2008,2013 Patrick Mevzek . All rights reserved.
4             ##
5             ## This file is part of Net::DRI
6             ##
7             ## Net::DRI is free software; you can redistribute it and/or modify
8             ## it under the terms of the GNU General Public License as published by
9             ## the Free Software Foundation; either version 2 of the License, or
10             ## (at your option) any later version.
11             ##
12             ## See the LICENSE file that comes with this distribution for more details.
13             #########################################################################################
14              
15             package Net::DRI::Data::Contact::US;
16              
17 2     2   7 use strict;
  2         4  
  2         66  
18 2     2   8 use warnings;
  2         1  
  2         48  
19              
20 2     2   8 use base qw/Net::DRI::Data::Contact/;
  2         2  
  2         473  
21 2     2   9 use Net::DRI::Util;
  2         7  
  2         37  
22 2     2   7 use Net::DRI::Exception;
  2         4  
  2         436  
23              
24             __PACKAGE__->register_attributes(qw(application_purpose nexus_category));
25              
26             =pod
27              
28             =head1 NAME
29              
30             Net::DRI::Data::Contact::US - Handle .US contact data for Net::DRI
31              
32             =head1 DESCRIPTION
33              
34             This subclass of Net::DRI::Data::Contact adds accessors and validation for
35             .US specific data.
36              
37             =head1 METHODS
38              
39             The following accessors/mutators can be called in chain, as they all return the object itself.
40             They are needed only for registrant contacts.
41              
42             =head2 application_purpose()
43              
44             intended usage for the domain name
45              
46             =head2 nexus_category()
47              
48             the nexus cateogry
49              
50             =head1 SUPPORT
51              
52             For now, support questions should be sent to:
53              
54             Enetdri@dotandco.comE
55              
56             Please also see the SUPPORT file in the distribution.
57              
58             =head1 SEE ALSO
59              
60             http://www.dotandco.com/services/software/Net-DRI/
61              
62             =head1 AUTHOR
63              
64             Patrick Mevzek, Enetdri@dotandco.comE
65              
66             =head1 COPYRIGHT
67              
68             Copyright (c) 2006-2008,2013 Patrick Mevzek .
69             All rights reserved.
70              
71             This program is free software; you can redistribute it and/or modify
72             it under the terms of the GNU General Public License as published by
73             the Free Software Foundation; either version 2 of the License, or
74             (at your option) any later version.
75              
76             See the LICENSE file that comes with this distribution for more details.
77              
78             =cut
79              
80             ####################################################################################################
81              
82             sub validate
83             {
84 0     0 0   my ($self,$change)=@_;
85 0   0       $change||=0;
86 0           my @errs;
87              
88 0           $self->SUPER::validate($change); ## will trigger an Exception if problem
89              
90 0 0         if (defined($self->application_purpose()))
91             {
92 0 0 0       push @errs,'application_purpose' unless ($self->application_purpose()=~m/^P[1-5]$/ || ($change && ($self->application_purpose() eq '')));
      0        
93             }
94              
95 0 0         if (defined($self->nexus_category()))
96             {
97 0 0 0       push @errs,'nexus_category' unless ($self->nexus_category()=~m!^C(?:1[12]|21|3[12]/([A-Z][A-Z]))$! || ($change && ($self->nexus_category() eq '')));
      0        
98 0 0 0       push @errs,'nexus_category' if ($1 && !exists($Net::DRI::Util::CCA2{$1}));
99             }
100              
101 0 0         Net::DRI::Exception::usererr_invalid_parameters('Invalid contact information: '.join('/',@errs)) if @errs;
102              
103 0           return 1; ## everything ok.
104             }
105              
106             ####################################################################################################
107             1;