Syccess/Validator/Regex.pm

filter: Statementstmt 100% 14 / 14 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod 0.0% 0 / 1 totaltotal 95.4% 21 / 22 CC 3 SCAR 7.9
CC
3
Cov
100%
validator
3.0
BEGIN
1.0
_build_message
1.0
CRAP 2.2
« Syccess/Validator/Required.pm ↑ Summary Syccess/Error.pm »
1 package Syccess::Validator::Regex;
2 2 our $AUTHORITY = 'cpan:GETTY';
3 # ABSTRACT: A validator to check with a regex
4 2 $Syccess::Validator::Regex::VERSION = '0.104';
5 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 with qw(
8 Syccess::ValidatorSimple
9 );
10  
11 2 has message => (
12 is => 'lazy',
13 );
14  
15 1 ▶sub _build_message {
Subroutine _build_message: called CC=1 SCAR=0.0
16 1 return 'Your value for %s is not valid.';
17 }
18  
19 4 ▶sub validator {
Subroutine validator: called CC=3 SCAR=11.0
Pod undocumented
20 4 my ( $self, $value ) = @_;
21 4 my $regex = $self->arg;
22 4 ▶ my $r = ref $regex eq 'Regexp' ? $regex : qr{$regex};
Branch: 1 branch
BranchTrueFalseTotal
ref $regex eq 'Regexp' ? : 2 2 4
23 4 ▶ return $self->message unless $value =~ m/$r/;
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ /$r/ 2 2 4
24 2 return;
25 }
26  
27 2 1;
28  
29 __END__
« Syccess/Validator/Required.pm ↑ Summary Syccess/Error.pm »