line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::FormFu::Validator::Callback; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
787
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
127
|
|
4
|
|
|
|
|
|
|
our $VERSION = '2.05'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
10
|
use Moose; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
57
|
|
7
|
3
|
|
|
3
|
|
12267
|
use MooseX::Attribute::FormFuChained; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
278
|
|
8
|
|
|
|
|
|
|
extends 'HTML::FormFu::Validator'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has callback => ( is => 'rw', traits => ['FormFuChained'] ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub validate_value { |
13
|
8
|
|
|
8
|
0
|
9
|
my ( $self, $value, $params ) = @_; |
14
|
|
|
|
|
|
|
|
15
|
8
|
|
50
|
0
|
|
230
|
my $callback = $self->callback || sub {1}; |
|
0
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
## no critic (ProhibitNoStrict); |
18
|
3
|
|
|
3
|
|
13
|
no strict 'refs'; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
221
|
|
19
|
|
|
|
|
|
|
|
20
|
8
|
|
|
|
|
21
|
my $ok = $callback->($value, $params); |
21
|
|
|
|
|
|
|
|
22
|
8
|
|
|
|
|
3583
|
return $ok; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
__END__ |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 NAME |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
HTML::FormFu::Validator::Callback - Callback validator |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 VERSION |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
version 2.05 |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 SYNOPSIS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$field->validator('Callback')->callback( \&my_validator ); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
--- |
44
|
|
|
|
|
|
|
elements: |
45
|
|
|
|
|
|
|
- type: Text |
46
|
|
|
|
|
|
|
name: foo |
47
|
|
|
|
|
|
|
validators: |
48
|
|
|
|
|
|
|
- type: Callback |
49
|
|
|
|
|
|
|
callback: "main::my_validator" |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 DESCRIPTION |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Callback validator. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
The first argument passed to the callback is the submitted value for the |
56
|
|
|
|
|
|
|
associated field. The second argument passed to the callback is a hashref of |
57
|
|
|
|
|
|
|
name/value pairs for all input fields. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 METHODS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 callback |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Arguments: \&code-reference |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Arguments: "subroutine-name" |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 SEE ALSO |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Is a sub-class of, and inherits methods from L<HTML::FormFu::Validator> |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
L<HTML::FormFu> |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 AUTHOR |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Carl Franks C<cfranks@cpan.org> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 LICENSE |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
80
|
|
|
|
|
|
|
the same terms as Perl itself. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |