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