File Coverage

blib/lib/Data/RuledValidator/Plugin/Core.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package Data::RuledValidator::Plugin::Core;
2              
3 6     6   33 use strict;
  6         11  
  6         232  
4 6     6   30 use warnings;
  6         9  
  6         196  
5 6     6   31 use Carp;
  6         8  
  6         416  
6 6     6   6051 use Email::Valid ();
  6         1163207  
  6         9117  
7              
8             our $VERSION = '0.04';
9              
10             Data::RuledValidator->add_condition_operator
11             (
12             'num' => sub{my($self, $v) = @_; return $v =~/^\d+$/},
13             'number' => sub{my($self, $v) = @_; return $v =~/^\d+$/},
14             'alpha' => sub{my($self, $v) = @_; return $v =~/^[a-zA-Z]+$/},
15             'alphanum' => sub{my($self, $v) = @_; return $v =~/^[a-zA-Z0-9]+$/},
16             'word' => sub{my($self, $v) = @_; return $v =~/^\w+$/},
17             'words' => sub{my($self, $v) = @_; return $v =~/^[\w\s]+$/},
18             'any' => sub{my($self, $v) = @_; return (defined $v and $v ne '')},
19             'not_null' => sub{my($self, $v) = @_; return (defined $v and $v ne '')},
20             'null' => sub{my($self, $v) = @_; return (not defined $v or $v eq '')},
21             );
22              
23             1;
24             __END__