Workflow/Validator/HasRequiredField.pm

filter: Statementstmt 91.6% 22 / 24 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 88.5% 31 / 35 CC 4 SCAR 9.5
CC
4
Cov
86%
validate
4.6
BEGIN
1.0
BEGIN
1.0
CRAP 2.6
« Workflow/Validator/MatchesDateFormat.pm ↑ Summary Workflow/Persister/File.pm »
1 package Workflow::Validator::HasRequiredField;
2  
3 30 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 30 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 30 ▶use v5.14.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 30 ▶use parent qw( Workflow::Validator );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 30 ▶use Workflow::Exception qw( validation_error );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 30 $Workflow::Validator::HasRequiredField::VERSION = '2.12';
10  
11 36 ▶sub validate {
Subroutine validate: called CC=4 SCAR=15.2
Pod documented
12 36 my ( $self, $wf, @required_fields ) = @_;
13 36 my $context = $wf->context;
14 36 my @no_value = ();
15 36 foreach my $field (@required_fields) {
16 36 ▶ unless ( defined $context->param($field) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $context->param($field)) 0 36 36
17 0 push @no_value, $field;
18 }
19 }
20 36 ▶ if ( scalar @no_value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @no_value) 0 36 36
21 0 validation_error "The following fields require a value: ",
22 join(', ',@no_value), { invalid_fields => \@no_value };
23 }
24 }
25  
26 30 1;
27  
28 __END__
« Workflow/Validator/MatchesDateFormat.pm ↑ Summary Workflow/Persister/File.pm »