File Coverage

blib/lib/Interface/Validation/Directive/Validator/Required.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             # Interface::Validation Validator Directive Required
2             package Interface::Validation::Directive::Validator::Required;
3              
4 1     1   26421 use Bubblegum;
  1         158489  
  1         8  
5 1     1   760338 use Function::Parameters;
  1         3148  
  1         8  
6 1     1   863 use Moose;
  0            
  0            
7              
8             use Bubblegum::Constraints -minimal;
9              
10             our $VERSION = '0.01_01'; # VERSION
11              
12             extends 'Interface::Validation::Directive';
13             with 'Interface::Validation::DirectiveRole::Execute::OnStart';
14             with 'Interface::Validation::DirectiveRole::Field';
15             with 'Interface::Validation::DirectiveRole::Mixin::Default';
16             with 'Interface::Validation::DirectiveRole::Validator';
17              
18             method error {
19             return '#{label} is required'
20             }
21              
22             method start {
23             my $exec = _object shift;
24             my $field = _object shift;
25              
26             my $param = shift;
27             my @args = $self->args_list;
28              
29             if (scalar _integer $args[0]) {
30             return $self->exception($exec, $field, $param)
31             if ! defined $param || $param eq '';
32             }
33              
34             return;
35             }
36              
37             1;