File Coverage

blib/lib/Net/DRI/Data/Contact/OpenSRS.pm
Criterion Covered Total %
statement 12 24 50.0
branch 0 8 0.0
condition 0 17 0.0
subroutine 4 6 66.6
pod 1 2 50.0
total 17 57 29.8


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, Handling of contact data for OpenSRS
2             ##
3             ## Copyright (c) 2009,2013 Richard Siddall . 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::OpenSRS;
16              
17 1     1   604 use strict;
  1         1  
  1         22  
18 1     1   3 use warnings;
  1         2  
  1         20  
19              
20 1     1   3 use base qw/Net::DRI::Data::Contact/;
  1         2  
  1         54  
21              
22 1     1   3 use Net::DRI::Exception;
  1         1  
  1         209  
23              
24             __PACKAGE__->register_attributes(qw(firstname url));
25              
26             =pod
27              
28             =head1 NAME
29              
30             Net::DRI::Data::Contact::OpenSRS - Handle OpenSRS contact data for Net::DRI
31              
32             =head1 DESCRIPTION
33              
34             This subclass of Net::DRI::Data::Contact adds accessors and validation for
35             OpenSRS 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              
41             =head2 firstname()
42              
43             Please note that for OpenSRS data, the name() must be only the lastname, hence this extra firstname() method
44              
45             =head2 lastname()
46              
47             Alias for name()
48              
49             =head1 SUPPORT
50              
51             For now, support questions should be sent to:
52              
53             Enetdri@dotandco.comE
54              
55             Please also see the SUPPORT file in the distribution.
56              
57             =head1 SEE ALSO
58              
59             http://www.dotandco.com/services/software/Net-DRI/
60              
61             =head1 AUTHOR
62              
63             Richard Siddall, Enetdri@elirion.net
64              
65             =head1 COPYRIGHT
66              
67             Copyright (c) 2009,2013 Richard Siddall .
68             All rights reserved.
69              
70             This program is free software; you can redistribute it and/or modify
71             it under the terms of the GNU General Public License as published by
72             the Free Software Foundation; either version 2 of the License, or
73             (at your option) any later version.
74              
75             See the LICENSE file that comes with this distribution for more details.
76              
77             =cut
78              
79             ####################################################################################################
80              
81             sub validate
82             {
83 0     0 0   my ($self,$change)=@_;
84 0   0       $change||=0;
85 0           my @errs;
86              
87 0           $self->SUPER::validate($change); ## will trigger an Exception if problem
88              
89 0 0 0       push @errs,'firstname' if ($self->firstname() && grep { !Net::DRI::Util::xml_is_normalizedstring($_,1,255) } ($self->firstname()));
  0            
90              
91 0 0 0       push @errs,'voice' if ($self->voice() && !Net::DRI::Util::xml_is_token($self->voice(),undef,17) && $self->voice()!~m/^\+[0-9]{1,3}\.[0-9]{1,12}(?:x\d{1,4})?$/);
      0        
92 0 0 0       push @errs,'fax' if ($self->fax() && !Net::DRI::Util::xml_is_token($self->fax(),undef,17) && $self->fax()!~m/^\+[0-9]{1,3}\.[0-9]{1,12}(?:x\d{1,4})?$/);
      0        
93              
94 0 0         Net::DRI::Exception::usererr_invalid_parameters('Invalid contact information: '.join('/',@errs)) if @errs;
95 0           return 1; ## everything ok.
96             }
97              
98             sub lastname {
99 0     0 1   my ($self, $change) = @_;
100 0           return $self->name($change);
101             }
102              
103             ####################################################################################################
104             1;