File Coverage

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


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