File Coverage

blib/lib/Net/DRI/Data/Contact/IT.pm
Criterion Covered Total %
statement 12 21 57.1
branch 0 8 0.0
condition 0 11 0.0
subroutine 4 5 80.0
pod 0 1 0.0
total 16 46 34.7


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, Handling of contact data for .IT
2             ##
3             ## Copyright (C) 2009-2010 Tower Technologies. All rights reserved.
4             ##
5             ## This program free software; you can redistribute it and/or modify
6             ## it under the terms of the GNU General Public License v2.
7              
8             package Net::DRI::Data::Contact::IT;
9              
10 1     1   858 use strict;
  1         1  
  1         28  
11 1     1   3 use warnings;
  1         1  
  1         25  
12              
13 1     1   4 use base qw / Net::DRI::Data::Contact /;
  1         2  
  1         66  
14              
15 1     1   5 use Net::DRI::Exception;
  1         2  
  1         206  
16              
17             __PACKAGE__->register_attributes(qw/
18             consent_for_publishing entity_type
19             nationality_code reg_code /);
20              
21             =pod
22              
23             =head1 NAME
24              
25             Net::DRI::Data::Contact::IT - Handle .IT contact data for Net::DRI
26              
27             =head1 SUPPORT
28              
29             For now, support questions should be sent to:
30              
31             Enoc@towertech.itE
32              
33             Please also see the SUPPORT file in the distribution.
34              
35             =head1 AUTHOR
36              
37             Alessandro Zummo, Ea.zummo@towertech.itE
38              
39             =head1 COPYRIGHT
40              
41             Copyright (C) 2009-2010 Tower Technologies.
42             All rights reserved.
43              
44             This program is free software; you can redistribute it and/or modify
45             it under the terms of the GNU General Public License v2 as published by
46             the Free Software Foundation.
47              
48             See the LICENSE file that comes with this distribution for more details.
49              
50              
51             =cut
52              
53              
54             sub validate
55             {
56 0     0 0   my ($self, $change) = @_;
57 0   0       $change ||= 0;
58 0           my @errs;
59            
60 0           $self->SUPER::validate($change);
61              
62 0 0 0       push @errs, 'consent_for_publishing'
63             if defined $self->consent_for_publishing
64             and $self->consent_for_publishing !~m/^(?:0|1)$/;
65            
66 0 0 0       push @errs, 'nationality_code'
67             if defined $self->nationality_code
68             and $self->nationality_code !~m/^[a-zA-Z]{2}$/;
69            
70 0 0 0       push @errs, 'entity_type'
71             if defined $self->entity_type
72             and $self->entity_type !~m/^[1-7]$/;
73            
74 0 0         Net::DRI::Exception::usererr_invalid_parameters('Invalid contact information: ' . join('/', @errs))
75             if scalar @errs;
76              
77 0           return 1;
78             }
79              
80             1;