File Coverage

blib/lib/Net/DRI/Data/Contact/CAT.pm
Criterion Covered Total %
statement 18 28 64.2
branch 0 10 0.0
condition 0 17 0.0
subroutine 6 7 85.7
pod 0 1 0.0
total 24 63 38.1


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, Handling of contact data for .CAT
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::CAT;
16              
17 2     2   6 use strict;
  2         2  
  2         52  
18 2     2   7 use warnings;
  2         3  
  2         54  
19              
20 2     2   6 use base qw/Net::DRI::Data::Contact/;
  2         4  
  2         589  
21 2     2   9 use Email::Valid;
  2         4  
  2         39  
22 2     2   6 use Net::DRI::Util;
  2         2  
  2         29  
23 2     2   6 use Net::DRI::Exception;
  2         2  
  2         383  
24              
25             __PACKAGE__->register_attributes(qw(lang email_sponsor maintainer));
26              
27             =pod
28              
29             =head1 NAME
30              
31             Net::DRI::Data::Contact::CAT - Handle .CAT contact data for Net::DRI
32              
33             =head1 DESCRIPTION
34              
35             This subclass of Net::DRI::Data::Contact adds accessors and validation for
36             .CAT specific data.
37              
38             .CAT uses only localized data.
39              
40             =head1 METHODS
41              
42             The following accessors/mutators can be called in chain, as they all return the object itself.
43              
44             =head2 lang()
45              
46             optional language of contact, according to RFC3066
47              
48             =head2 maintainer()
49              
50             optional free-form element that is published in whois
51              
52             =head2 email_sponsor()
53              
54             e-mail address to use when participating in the community sponsoring model of the puntCAT registry ;
55             may be identical to the primary e-mail address
56              
57             =head1 SUPPORT
58              
59             For now, support questions should be sent to:
60              
61             Enetdri@dotandco.comE
62              
63             Please also see the SUPPORT file in the distribution.
64              
65             =head1 SEE ALSO
66              
67             http://www.dotandco.com/services/software/Net-DRI/
68              
69             =head1 AUTHOR
70              
71             Patrick Mevzek, Enetdri@dotandco.comE
72              
73             =head1 COPYRIGHT
74              
75             Copyright (c) 2006,2008,2013 Patrick Mevzek .
76             All rights reserved.
77              
78             This program is free software; you can redistribute it and/or modify
79             it under the terms of the GNU General Public License as published by
80             the Free Software Foundation; either version 2 of the License, or
81             (at your option) any later version.
82              
83             See the LICENSE file that comes with this distribution for more details.
84              
85             =cut
86              
87             ####################################################################################################
88              
89             sub validate
90             {
91 0     0 0   my ($self,$change)=@_;
92 0   0       $change||=0;
93 0           my @errs;
94              
95 0           $self->SUPER::validate($change); ## will trigger an Exception if problem
96              
97 0 0 0       push @errs,'lang' if ($self->lang() && !Net::DRI::Util::xml_is_language($self->lang()));
98 0 0 0       push @errs,'maintainer' if ($self->maintainer() && !Net::DRI::Util::xml_is_token($self->maintainer(),undef,128));
99 0 0 0       push @errs,'email_sponsor' if ($self->email_sponsor() && !Net::DRI::Util::xml_is_token($self->email_sponsor(),1,undef) && !Email::Valid->rfc822($self->email_sponsor()));
      0        
100              
101 0 0 0       push @errs,'srid' if ($self->srid() && $self->srid()=~m/^REG-/);
102              
103 0 0         Net::DRI::Exception::usererr_invalid_parameters('Invalid contact information: '.join('/',@errs)) if @errs;
104              
105 0           return 1; ## everything ok.
106             }
107              
108             ####################################################################################################
109             1;