File Coverage

blib/lib/CGI/Untaint/telephone.pm
Criterion Covered Total %
statement 17 17 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 24 24 100.0


line stmt bran cond sub pod time code
1             package CGI::Untaint::telephone;
2              
3 1     1   26331 use 5.006001;
  1         4  
  1         39  
4 1     1   5 use strict;
  1         2  
  1         28  
5 1     1   4 use warnings;
  1         6  
  1         44  
6              
7             our $VERSION = '0.03';
8              
9 1     1   5 use base 'CGI::Untaint::object';
  1         1  
  1         775  
10              
11             # a rather basic regex for phone numbers here..
12             # it should really try and guarantee that if there ARE dots and dashes,
13             # that they can't occur next to each other..
14             sub _untaint_re {
15 7     7   8239 return qr/^\+?\d[-\.\d ]{1,24}$/;
16             }
17              
18             sub is_valid {
19 2     2 1 31 my $self = shift;
20 2         7 my $value = $self->value;
21 2         19 $value =~ s/[-\.\s]//g;
22 2         9 return $self->value($value);
23             }
24              
25             1;
26             __END__