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
|
|
626
|
use 5.10.0; |
|
1
|
|
|
|
|
3
|
|
6
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
16
|
|
7
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use base 'Validation::Class::Simple'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
396
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
55
|
|
12
|
1
|
|
|
1
|
|
7
|
use Validation::Class::Util; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
5
|
use overload bool => \&validate, '""' => \&messages, fallback => 1; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '7.900058'; # VERSION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
2
|
0
|
458
|
my $class = shift; |
23
|
2
|
|
66
|
|
|
9
|
$class = ref $class || $class; |
24
|
2
|
|
|
|
|
11
|
my $self = $class->SUPER::new(@_); |
25
|
|
|
|
|
|
|
|
26
|
2
|
|
|
|
|
31
|
$self->{action} = ''; |
27
|
2
|
|
|
|
|
3
|
$self->{target} = ''; |
28
|
|
|
|
|
|
|
|
29
|
2
|
|
|
|
|
6
|
return $self; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub check { |
35
|
|
|
|
|
|
|
|
36
|
6
|
|
|
6
|
1
|
20
|
my ($self, $target) = @_; |
37
|
|
|
|
|
|
|
|
38
|
6
|
50
|
|
|
|
15
|
if ($target) { |
39
|
|
|
|
|
|
|
|
40
|
6
|
50
|
|
|
|
15
|
return $self if $target eq $self->{target}; |
41
|
|
|
|
|
|
|
|
42
|
6
|
50
|
|
|
|
14
|
$self->prototype->fields->add($target => {name => $target}) |
43
|
|
|
|
|
|
|
unless $self->prototype->fields->has($target); |
44
|
|
|
|
|
|
|
|
45
|
6
|
|
|
|
|
15
|
$self->prototype->queue($self->{target} = $target); |
46
|
6
|
|
|
|
|
12
|
$self->prototype->normalize($self); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
6
|
|
|
|
|
43
|
return $self; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub clear { |
56
|
|
|
|
|
|
|
|
57
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
3
|
$self->prototype->queued->clear; |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
4
|
$self->prototype->reset_fields; |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
2
|
return $self; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub declare { |
68
|
|
|
|
|
|
|
|
69
|
17
|
|
|
17
|
0
|
37
|
my ($self, @config) = @_; |
70
|
|
|
|
|
|
|
|
71
|
17
|
|
|
|
|
24
|
my $arguments = pop(@config); |
72
|
17
|
|
33
|
|
|
56
|
my $action = shift(@config) || $self->{action}; |
73
|
17
|
|
|
|
|
25
|
my $target = $self->{target}; |
74
|
|
|
|
|
|
|
|
75
|
17
|
50
|
|
|
|
28
|
return $self unless $target; |
76
|
|
|
|
|
|
|
|
77
|
17
|
|
|
|
|
40
|
$self->prototype->queue($target); # if clear() was called or check() wasn't |
78
|
|
|
|
|
|
|
|
79
|
17
|
100
|
|
|
|
34
|
unless ($arguments) { |
80
|
9
|
50
|
|
|
|
21
|
$arguments = 1 if $action eq 'city'; |
81
|
9
|
50
|
|
|
|
16
|
$arguments = 1 if $action eq 'creditcard'; |
82
|
9
|
50
|
|
|
|
16
|
$arguments = 1 if $action eq 'date'; |
83
|
9
|
50
|
|
|
|
16
|
$arguments = 1 if $action eq 'decimal'; |
84
|
9
|
100
|
|
|
|
17
|
$arguments = 1 if $action eq 'email'; |
85
|
9
|
50
|
|
|
|
16
|
$arguments = 1 if $action eq 'hostname'; |
86
|
9
|
50
|
|
|
|
39
|
$arguments = 1 if $action eq 'multiples'; |
87
|
9
|
100
|
|
|
|
21
|
$arguments = 1 if $action eq 'required'; |
88
|
9
|
50
|
|
|
|
15
|
$arguments = 1 if $action eq 'ssn'; |
89
|
9
|
50
|
|
|
|
17
|
$arguments = 1 if $action eq 'state'; |
90
|
9
|
100
|
|
|
|
15
|
$arguments = 1 if $action eq 'telephone'; |
91
|
9
|
50
|
|
|
|
12
|
$arguments = 1 if $action eq 'time'; |
92
|
9
|
50
|
|
|
|
16
|
$arguments = 1 if $action eq 'uuid'; |
93
|
9
|
50
|
|
|
|
15
|
$arguments = 1 if $action eq 'zipcode'; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
17
|
50
|
|
|
|
34
|
if ($self->prototype->fields->has($target)) { |
97
|
|
|
|
|
|
|
|
98
|
17
|
|
|
|
|
37
|
my $field = $self->prototype->fields->get($target); |
99
|
|
|
|
|
|
|
|
100
|
17
|
50
|
|
|
|
61
|
if ($field->can($action)) { |
101
|
|
|
|
|
|
|
|
102
|
17
|
50
|
|
|
|
61
|
$field->$action($arguments) if defined $arguments; |
103
|
|
|
|
|
|
|
|
104
|
17
|
|
|
|
|
65
|
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
|
|
|
|
|
8
|
return $self->prototype->errors_to_string(@arguments); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub validate { |
127
|
|
|
|
|
|
|
|
128
|
12
|
|
|
12
|
1
|
496
|
my ($self) = @_; |
129
|
|
|
|
|
|
|
|
130
|
12
|
|
|
|
|
23
|
my $true = $self->prototype->validate($self); |
131
|
|
|
|
|
|
|
|
132
|
12
|
|
|
|
|
46
|
return $true; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub AUTOLOAD { |
137
|
|
|
|
|
|
|
|
138
|
17
|
|
|
17
|
|
313
|
(my $routine = $Validation::Class::Simple::Streamer::AUTOLOAD) =~ s/.*:://; |
139
|
|
|
|
|
|
|
|
140
|
17
|
|
|
|
|
33
|
my ($self) = @_; |
141
|
|
|
|
|
|
|
|
142
|
17
|
50
|
|
|
|
41
|
if ($routine) { |
143
|
|
|
|
|
|
|
|
144
|
17
|
|
|
|
|
28
|
$self->{action} = $routine; |
145
|
|
|
|
|
|
|
|
146
|
17
|
|
|
|
|
48
|
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__ |