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