| 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
Condition100%3/3
defined $_[0] and $_[0] ne ""
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 ""
| |||||||||||||||||||||||||||||
| 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
Condition100%3/3
not defined $_[0] or $_[0] ne ""
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 ""
| |||||||||||||||||||||||||||||
| 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
Condition100%3/3
not defined $list or $list eq ""
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 ""
| |||||||||||||||||||||||||||||
| 24 | 6 | ▶ | return 'FORMAT_ERROR' if ref($list) ne 'ARRAY'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | 5 | ▶ | return 'CANNOT_BE_EMPTY' unless scalar @$list; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition100%3/3
not defined $value or $value eq ""
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 ""
| |||||||||||||||||||||||||||||
| 34 | 8 | ▶ | return 'FORMAT_ERROR' if ref($value) ne 'HASH'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||||