| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Catalyst::Plugin::FormValidator; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
22952
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
31
|
|
|
4
|
1
|
|
|
1
|
|
2474
|
use MRO::Compat; |
|
|
1
|
|
|
|
|
2981
|
|
|
|
1
|
|
|
|
|
25
|
|
|
5
|
1
|
|
|
1
|
|
2083
|
use Data::FormValidator; |
|
|
1
|
|
|
|
|
36850
|
|
|
|
1
|
|
|
|
|
208
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.094'; |
|
8
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head2 prepare |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Override Catalyst's prepare |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub prepare { |
|
17
|
0
|
|
|
0
|
1
|
|
my $c = shift; |
|
18
|
0
|
|
|
|
|
|
$c = $c->maybe::next::method(@_); |
|
19
|
0
|
|
|
|
|
|
$c->{form} = Data::FormValidator->check( $c->request->parameters, {} ); |
|
20
|
0
|
|
|
|
|
|
return $c; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 form |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$c->form object |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub form { |
|
31
|
0
|
|
|
0
|
1
|
|
my $c = shift; |
|
32
|
0
|
0
|
|
|
|
|
if ( $_[0] ) { |
|
33
|
0
|
0
|
|
|
|
|
my $form = $_[1] ? {@_} : $_[0]; |
|
34
|
0
|
|
|
|
|
|
$c->{form} = |
|
35
|
|
|
|
|
|
|
Data::FormValidator->check( $c->request->parameters, $form ); |
|
36
|
|
|
|
|
|
|
} |
|
37
|
0
|
|
|
|
|
|
return $c->{form}; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
=head1 NAME |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Catalyst::Plugin::FormValidator - Data::FormValidator |
|
42
|
|
|
|
|
|
|
plugin for Catalyst. |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
use Catalyst 'FormValidator'; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$c->form( optional => ['rest'] ); |
|
49
|
|
|
|
|
|
|
print $c->form->valid('rest'); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Note that not only is this plugin disrecommended (as it takes over the global |
|
53
|
|
|
|
|
|
|
C<< $c->form >> method, rather than being applyable in only part of your |
|
54
|
|
|
|
|
|
|
application), but L<Data::FormValidator> itself is not recommended for use. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This plugin uses L<Data::FormValidator> to validate and set up form data |
|
59
|
|
|
|
|
|
|
from your request parameters. It's a quite thin wrapper around that |
|
60
|
|
|
|
|
|
|
module, so most of the relevant information can be found there. |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 EXTENDED METHODS |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 METHODS |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head3 form |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Merge values with FormValidator. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
$c->form( required => ['yada'] ); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Returns a L<Data::FormValidator::Results> object. |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$c->form->valid('rest'); |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
The actual parameters sent to $c->form are the same as the profile in |
|
77
|
|
|
|
|
|
|
L<Data::FormValidator>'s check function. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
L<Catalyst>, L<Data::FormValidator> |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 AUTHOR |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Sebastian Riedel, C<sri@cpan.org> |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Devin Austin C<(dhoss@cpan.org)> |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
|
96
|
|
|
|
|
|
|
the same terms as Perl itself. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |