LIVR/Rules/Common.pm

filter: Statementstmt 100% 22 / 22 Branchbran 100% 14 / 14 Conditioncond 100% 12 / 12 MC/DCmcdc 100% 8 / 8 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 4 totaltotal 94.2% 66 / 70 CC 12 SCAR 11.3
CC
12
Cov
100%
__ANON__
5.0
__ANON__
4.0
__ANON__
3.0
CRAP 3.1
« LIVR/Rules/Modifiers.pm ↑ Summary
1 package Validator::LIVR::Rules::Common;
2  
3 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 10 our $VERSION = '2.22';
7  
8 496 ▶sub required {
Subroutine required: called CC=1 SCAR=0.0
Pod undocumented
9 381 ▶ return sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
10 381 ▶ defined $_[0] && $_[0] ne '' ? undef : 'REQUIRED';
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] && $_[0] ne '' ? : 302 79 381
Condition100%3/3
defined $_[0] and $_[0] ne ""
!ll&&!rl&&r
4831302
MC/DC100%2/2
defined $_[0] and $_[0] ne ""
defined $_[0] $_[0] ne ""
Truth table100%3/3
A and B
A= defined $_[0]B= $_[0] ne ""
ABresult
0X0
100
111
11 }
12 496 }
13  
14 35 ▶sub not_empty {
Subroutine not_empty: called CC=1 SCAR=0.0
Pod undocumented
15 23 ▶ return sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
16 23 ▶ ! defined $_[0] || $_[0] ne '' ? undef : "CANNOT_BE_EMPTY"
Branch: 1 branch
BranchTrueFalseTotal
!defined($_[0]) || $_[0] ne '' ? : 21 2 23
Condition100%3/3
not defined $_[0] or $_[0] ne ""
l!l&&r!l&&!r
4172
MC/DC100%2/2
not defined $_[0] or $_[0] ne ""
not defined $_[0] $_[0] ne ""
Truth table100%3/3
not(A) or B
A= not defined $_[0]B= $_[0] ne ""
ABresult
1X1
011
000
17 35 };
18 }
19  
20 8 ▶sub not_empty_list {
Subroutine not_empty_list: called CC=1 SCAR=0.0
Pod undocumented
21 8 ▶ return sub {
Subroutine __ANON__: called CC=5 SCAR=16.1
22 8 my $list = shift;
23 8 ▶ return 'CANNOT_BE_EMPTY' if !defined($list) || $list eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $list or $list eq "" 2 6 8
Condition100%3/3
not defined $list or $list eq ""
l!l&&r!l&&!r
116
MC/DC100%2/2
not defined $list or $list eq ""
not defined $list $list eq ""
Truth table100%3/3
not(A) or B
A= not defined $listB= $list eq ""
ABresult
1X1
011
000
24 6 ▶ return 'FORMAT_ERROR' if ref($list) ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $list ne "ARRAY" 1 5 6
25 5 ▶ return 'CANNOT_BE_EMPTY' unless scalar @$list;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @$list 2 3 5
26 3 return;
27 }
28 8 }
29  
30 10 ▶sub any_object {
Subroutine any_object: called CC=1 SCAR=0.0
Pod undocumented
31 10 ▶ return sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
32 10 my $value = shift;
33 10 ▶ return if !defined($value) || $value eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $value or $value eq "" 2 8 10
Condition100%3/3
not defined $value or $value eq ""
l!l&&r!l&&!r
118
MC/DC100%2/2
not defined $value or $value eq ""
not defined $value $value eq ""
Truth table100%3/3
not(A) or B
A= not defined $valueB= $value eq ""
ABresult
1X1
011
000
34 8 ▶ return 'FORMAT_ERROR' if ref($value) ne 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $value ne "HASH" 4 4 8
35 }
36 10 }
37  
38 10 1;
39  
40 =head1 NAME
41  
42 Validator::LIVR::Rules::Common - Common rules of Validator::LIVR: required, not_empty, not_empty_list and any_object
43  
44 =head1 DESCRIPTION
45  
46 This module has the code of the common rules, which are documented in
47 L<Validator::LIVR/Common rules>.
48  
49 Each sub is the builder of the rule with the same name. The code is a good
50 example for L<writing your own rules|Validator::LIVR/WRITING RULES IN PERL>.
51  
52 =cut
« LIVR/Rules/Modifiers.pm ↑ Summary