|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # ABSTRACT: Required Directive for Validation Class Field Definitions  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Validation::Class::Directive::Required;  | 
| 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
5
 | 
109
 | 
 
 | 
 
 | 
  
109
  
 | 
 
 | 
61860
 | 
 use strict;  | 
| 
 
 | 
109
 | 
 
 | 
 
 | 
 
 | 
 
 | 
297
 | 
    | 
| 
 
 | 
109
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3499
 | 
    | 
| 
6
 | 
109
 | 
 
 | 
 
 | 
  
109
  
 | 
 
 | 
673
 | 
 use warnings;  | 
| 
 
 | 
109
 | 
 
 | 
 
 | 
 
 | 
 
 | 
254
 | 
    | 
| 
 
 | 
109
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3485
 | 
    | 
| 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
8
 | 
109
 | 
 
 | 
 
 | 
  
109
  
 | 
 
 | 
623
 | 
 use base 'Validation::Class::Directive';  | 
| 
 
 | 
109
 | 
 
 | 
 
 | 
 
 | 
 
 | 
278
 | 
    | 
| 
 
 | 
109
 | 
 
 | 
 
 | 
 
 | 
 
 | 
13097
 | 
    | 
| 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
10
 | 
109
 | 
 
 | 
 
 | 
  
109
  
 | 
 
 | 
849
 | 
 use Validation::Class::Util;  | 
| 
 
 | 
109
 | 
 
 | 
 
 | 
 
 | 
 
 | 
290
 | 
    | 
| 
 
 | 
109
 | 
 
 | 
 
 | 
 
 | 
 
 | 
835
 | 
    | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $VERSION = '7.900059'; # VERSION  | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has 'mixin'        => 1;  | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has 'field'        => 1;  | 
| 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has 'multi'        => 0;  | 
| 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has 'message'      => '%s is required';  | 
| 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has 'dependencies' => sub {{  | 
| 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     normalization => [],  | 
| 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     validation    => ['alias', 'toggle']  | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }};  | 
| 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
24
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub before_validation {  | 
| 
25
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
26
 | 
560
 | 
 
 | 
 
 | 
  
560
  
 | 
  
0
  
 | 
1614
 | 
     my ($self, $proto, $field, $param) = @_;  | 
| 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
28
 | 
560
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
1641
 | 
     if (defined $field->{required}) {  | 
| 
29
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
30
 | 
560
 | 
  
100
  
 | 
  
100
  
 | 
 
 | 
 
 | 
2316
 | 
         if ($field->{required} && (! defined $param || $param eq '')) {  | 
| 
 
 | 
 
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
31
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
32
 | 
36
 | 
 
 | 
 
 | 
 
 | 
 
 | 
379
 | 
             $self->error($proto, $field);  | 
| 
33
 | 
36
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
170
 | 
             $proto->stash->{'validation.bypass_event'}++  | 
| 
34
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 unless $proto->ignore_intervention;  | 
| 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
36
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
40
 | 
560
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1530
 | 
     return $self;  | 
| 
41
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
42
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
43
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub normalize {  | 
| 
45
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
46
 | 
1009
 | 
 
 | 
 
 | 
  
1009
  
 | 
  
0
  
 | 
2625
 | 
     my ($self, $proto, $field, $param) = @_;  | 
| 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
48
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     # by default, field validation is optional  | 
| 
49
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
50
 | 
1009
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
2825
 | 
     $field->{required} = 0 unless defined $field->{required};  | 
| 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
52
 | 
1009
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2538
 | 
     return $self;  | 
| 
53
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
55
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
56
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
57
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
58
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __END__  |