| 1 | package Validator::LIVR::Rules::Modifiers; | ||||||||||||||||||||||||||||||||||||||||||
| 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 | 10 | ▶ | sub trim { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trim: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 12 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 12 | my ( $value, undef, $output_ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 11 | 12 | ▶ | return if !defined($value) || ref($value) || $value eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
not defined $value or ref $value or $value eq ""
not defined $value or ref $value
MC/DC33%1/3
not defined $value or ref $value or $value eq ""
not defined $value
ref $value
$value eq ""
Truth table50%2/4
not(A) or B or C
A= not defined $valueB= ref $valueC= $value eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 11 | $$output_ref = $value; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 11 | $$output_ref =~ s/^\s*//; | |||||||||||||||||||||||||||||||||||||||||
| 15 | 11 | $$output_ref =~ s/\s*$//; | |||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 11 | return; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 10 | }; | |||||||||||||||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 46 | ▶ | sub to_lc { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_lc: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 34 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 34 | my ( $value, undef, $output_ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 34 | ▶ | return if !defined($value) || ref($value) || $value eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not defined $value or ref $value or $value eq ""
not defined $value or ref $value
MC/DC66%2/3
not defined $value or ref $value or $value eq ""
not defined $value
ref $value
$value eq ""
Truth table75%3/4
not(A) or B or C
A= not defined $valueB= ref $valueC= $value eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 32 | $$output_ref = lc($value); | |||||||||||||||||||||||||||||||||||||||||
| 27 | 32 | return; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 46 | }; | |||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 41 | ▶ | sub to_uc { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_uc: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 25 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 25 | my ( $value, undef, $output_ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 34 | 25 | ▶ | return if !defined($value) || ref($value) || $value eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not defined $value or ref $value or $value eq ""
not defined $value or ref $value
MC/DC66%2/3
not defined $value or ref $value or $value eq ""
not defined $value
ref $value
$value eq ""
Truth table75%3/4
not(A) or B or C
A= not defined $valueB= ref $valueC= $value eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 23 | $$output_ref = uc($value); | |||||||||||||||||||||||||||||||||||||||||
| 37 | 23 | return; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 41 | }; | |||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 4 | ▶ | sub remove { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 4 | my $chars = shift; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 4 | my $re = qr/[\Q$chars\E]/; | |||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 6 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 6 | my ( $value, undef, $output_ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 6 | ▶ | return if !defined($value) || ref($value) || $value eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
not defined $value or ref $value or $value eq ""
not defined $value or ref $value
MC/DC33%1/3
not defined $value or ref $value or $value eq ""
not defined $value
ref $value
$value eq ""
Truth table50%2/4
not(A) or B or C
A= not defined $valueB= ref $valueC= $value eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 5 | $value =~ s/$re//g; | |||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 5 | $$output_ref = $value; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 4 | }; | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 3 | ▶ | sub leave_only { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
leave_only: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 3 | my $chars = shift; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 3 | my $re = qr/[^\Q$chars\E]/; | |||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 5 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 5 | my ( $value, undef, $output_ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 5 | ▶ | return if !defined($value) || ref($value) || $value eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
not defined $value or ref $value or $value eq ""
not defined $value or ref $value
MC/DC33%1/3
not defined $value or ref $value or $value eq ""
not defined $value
ref $value
$value eq ""
Truth table50%2/4
not(A) or B or C
A= not defined $valueB= ref $valueC= $value eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 4 | $value =~ s/$re//g; | |||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 4 | $$output_ref = $value; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 14 | ▶ | sub default { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 14 | my $default_value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 14 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 14 | my ( $value, undef, $output_ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 14 | ▶ | 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 ""
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 10 | $$output_ref = $default_value; | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 14 | return; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 14 | }; | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 10 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | Validator::LIVR::Rules::Modifiers - Modifiers of Validator::LIVR: trim, to_lc, to_uc, remove, leave_only and default | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | This module has the code of the modifiers, which are documented in | ||||||||||||||||||||||||||||||||||||||||||
| 94 | L<Validator::LIVR/Modifiers>. | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | Each sub is the builder of the rule with the same name. The code is a good | ||||||||||||||||||||||||||||||||||||||||||
| 97 | example for L<writing your own rules|Validator::LIVR/WRITING RULES IN PERL>. | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | =cut | ||||||||||||||||||||||||||||||||||||||||||