line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Simple Streaming Data Validation |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Validation::Class::Simple::Streamer; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
878
|
use 5.10.0; |
|
1
|
|
|
|
|
4
|
|
6
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
7
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use base 'Validation::Class::Simple'; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
599
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
64
|
|
12
|
1
|
|
|
1
|
|
5
|
use Validation::Class::Util; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
5
|
use overload bool => \&validate, '""' => \&messages, fallback => 1; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '7.900057'; # VERSION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
2
|
0
|
823
|
my $class = shift; |
23
|
2
|
|
66
|
|
|
13
|
$class = ref $class || $class; |
24
|
2
|
|
|
|
|
21
|
my $self = $class->SUPER::new(@_); |
25
|
|
|
|
|
|
|
|
26
|
2
|
|
|
|
|
55
|
$self->{action} = ''; |
27
|
2
|
|
|
|
|
4
|
$self->{target} = ''; |
28
|
|
|
|
|
|
|
|
29
|
2
|
|
|
|
|
8
|
return $self; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub check { |
35
|
|
|
|
|
|
|
|
36
|
6
|
|
|
6
|
1
|
27
|
my ($self, $target) = @_; |
37
|
|
|
|
|
|
|
|
38
|
6
|
50
|
|
|
|
13
|
if ($target) { |
39
|
|
|
|
|
|
|
|
40
|
6
|
50
|
|
|
|
22
|
return $self if $target eq $self->{target}; |
41
|
|
|
|
|
|
|
|
42
|
6
|
50
|
|
|
|
22
|
$self->prototype->fields->add($target => {name => $target}) |
43
|
|
|
|
|
|
|
unless $self->prototype->fields->has($target); |
44
|
|
|
|
|
|
|
|
45
|
6
|
|
|
|
|
23
|
$self->prototype->queue($self->{target} = $target); |
46
|
6
|
|
|
|
|
20
|
$self->prototype->normalize($self); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
6
|
|
|
|
|
72
|
return $self; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub clear { |
56
|
|
|
|
|
|
|
|
57
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
7
|
$self->prototype->queued->clear; |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
5
|
$self->prototype->reset_fields; |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
2
|
return $self; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub declare { |
68
|
|
|
|
|
|
|
|
69
|
17
|
|
|
17
|
0
|
35
|
my ($self, @config) = @_; |
70
|
|
|
|
|
|
|
|
71
|
17
|
|
|
|
|
22
|
my $arguments = pop(@config); |
72
|
17
|
|
33
|
|
|
66
|
my $action = shift(@config) || $self->{action}; |
73
|
17
|
|
|
|
|
29
|
my $target = $self->{target}; |
74
|
|
|
|
|
|
|
|
75
|
17
|
50
|
|
|
|
39
|
return $self unless $target; |
76
|
|
|
|
|
|
|
|
77
|
17
|
|
|
|
|
63
|
$self->prototype->queue($target); # if clear() was called or check() wasn't |
78
|
|
|
|
|
|
|
|
79
|
17
|
100
|
|
|
|
47
|
unless ($arguments) { |
80
|
9
|
50
|
|
|
|
24
|
$arguments = 1 if $action eq 'city'; |
81
|
9
|
50
|
|
|
|
991
|
$arguments = 1 if $action eq 'creditcard'; |
82
|
9
|
50
|
|
|
|
24
|
$arguments = 1 if $action eq 'date'; |
83
|
9
|
50
|
|
|
|
21
|
$arguments = 1 if $action eq 'decimal'; |
84
|
9
|
100
|
|
|
|
18
|
$arguments = 1 if $action eq 'email'; |
85
|
9
|
50
|
|
|
|
23
|
$arguments = 1 if $action eq 'hostname'; |
86
|
9
|
50
|
|
|
|
19
|
$arguments = 1 if $action eq 'multiples'; |
87
|
9
|
100
|
|
|
|
20
|
$arguments = 1 if $action eq 'required'; |
88
|
9
|
50
|
|
|
|
19
|
$arguments = 1 if $action eq 'ssn'; |
89
|
9
|
50
|
|
|
|
21
|
$arguments = 1 if $action eq 'state'; |
90
|
9
|
100
|
|
|
|
18
|
$arguments = 1 if $action eq 'telephone'; |
91
|
9
|
50
|
|
|
|
21
|
$arguments = 1 if $action eq 'time'; |
92
|
9
|
50
|
|
|
|
17
|
$arguments = 1 if $action eq 'uuid'; |
93
|
9
|
50
|
|
|
|
21
|
$arguments = 1 if $action eq 'zipcode'; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
17
|
50
|
|
|
|
50
|
if ($self->prototype->fields->has($target)) { |
97
|
|
|
|
|
|
|
|
98
|
17
|
|
|
|
|
54
|
my $field = $self->prototype->fields->get($target); |
99
|
|
|
|
|
|
|
|
100
|
17
|
50
|
|
|
|
80
|
if ($field->can($action)) { |
101
|
|
|
|
|
|
|
|
102
|
17
|
50
|
|
|
|
77
|
$field->$action($arguments) if defined $arguments; |
103
|
|
|
|
|
|
|
|
104
|
17
|
|
|
|
|
85
|
return $self; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
0
|
|
|
0
|
exit carp sprintf q(Can't locate object method "%s" via package "%s"), |
111
|
|
|
|
|
|
|
$action, ((ref $_[0] || $_[0]) || 'main') |
112
|
|
|
|
|
|
|
; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub messages { |
118
|
|
|
|
|
|
|
|
119
|
2
|
|
|
2
|
1
|
6
|
my ($self, @arguments) = @_; |
120
|
|
|
|
|
|
|
|
121
|
2
|
|
|
|
|
11
|
return $self->prototype->errors_to_string(@arguments); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub validate { |
127
|
|
|
|
|
|
|
|
128
|
12
|
|
|
12
|
1
|
772
|
my ($self) = @_; |
129
|
|
|
|
|
|
|
|
130
|
12
|
|
|
|
|
39
|
my $true = $self->prototype->validate($self); |
131
|
|
|
|
|
|
|
|
132
|
12
|
|
|
|
|
64
|
return $true; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub AUTOLOAD { |
137
|
|
|
|
|
|
|
|
138
|
17
|
|
|
17
|
|
690
|
(my $routine = $Validation::Class::Simple::Streamer::AUTOLOAD) =~ s/.*:://; |
139
|
|
|
|
|
|
|
|
140
|
17
|
|
|
|
|
39
|
my ($self) = @_; |
141
|
|
|
|
|
|
|
|
142
|
17
|
50
|
|
|
|
43
|
if ($routine) { |
143
|
|
|
|
|
|
|
|
144
|
17
|
|
|
|
|
33
|
$self->{action} = $routine; |
145
|
|
|
|
|
|
|
|
146
|
17
|
|
|
|
|
61
|
goto &declare; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
0
|
|
0
|
|
|
|
croak sprintf q(Can't locate object method "%s" via package "%s"), |
151
|
|
|
|
|
|
|
$routine, ((ref $_[0] || $_[0]) || 'main') |
152
|
|
|
|
|
|
|
; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
0
|
|
|
sub DESTROY {} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
1; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
__END__ |