lib/HTML/FormFu/Validator/Callback.pm

filter: Statementstmt 95.4% 21 / 22 Branchbran n/a Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 79.4% 27 / 34 SCAR 7.0
CC
2
Cov
88%
validate_value
2.1
__ANON__
1.2
BEGIN
1.0
CRAP 2.0
« lib/HTML/FormFu/Transformer/Callback.pm ↑ Summary lib/HTML/FormFu/I18N/bg.pm »
1 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package HTML::FormFu::Validator::Callback;
4 3 $HTML::FormFu::Validator::Callback::VERSION = '2.06';
5 # ABSTRACT: Callback validator
6  
7 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use MooseX::Attribute::Chained;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 extends 'HTML::FormFu::Validator';
10  
11 3 has callback => ( is => 'rw', traits => ['Chained'] );
12  
13 sub validate_value {
14 8 ▶ my ( $self, $value, $params ) = @_;
Subroutine validate_value: called CC=2 SCAR=7.3
Pod undocumented
15  
16 8 ▶ my $callback = $self->callback || sub {1};
Subroutine __ANON__: not called CC=1 SCAR=2.0
Condition33%1/3
$self->callback || sub {
l!l&&r!l&&!r
800
MC/DC0%0/2
$self->callback || sub { 1; }
$self->callback sub { 1; }
Truth table33%1/3
A || B
A= $self->callbackB= sub { 1; }
ABresult
1X1
011
000
17  
18 ## no critic (ProhibitNoStrict);
19 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 8 my $ok = $callback->( $value, $params );
22  
23 8 return $ok;
24 }
25  
26 3 __PACKAGE__->meta->make_immutable;
27  
28 3 1;
29  
30 __END__
31  
32 =pod
33  
34 =encoding UTF-8
35  
36 =head1 NAME
37  
38 HTML::FormFu::Validator::Callback - Callback validator
39  
40 =head1 VERSION
41  
42 version 2.06
43  
44 =head1 SYNOPSIS
45  
46 $field->validator('Callback')->callback( \&my_validator );
47  
48 ---
49 elements:
50 - type: Text
51 name: foo
52 validators:
53 - type: Callback
54 callback: "main::my_validator"
55  
56 =head1 DESCRIPTION
57  
58 Callback validator.
59  
60 The first argument passed to the callback is the submitted value for the
61 associated field. The second argument passed to the callback is a hashref of
62 name/value pairs for all input fields.
63  
64 =head1 METHODS
65  
66 =head2 callback
67  
68 Arguments: \&code-reference
69  
70 Arguments: "subroutine-name"
71  
72 =head1 SEE ALSO
73  
74 Is a sub-class of, and inherits methods from L<HTML::FormFu::Validator>
75  
76 L<HTML::FormFu>
77  
78 =head1 AUTHOR
79  
80 Carl Franks C<cfranks@cpan.org>
81  
82 =head1 LICENSE
83  
84 This library is free software, you can redistribute it and/or modify it under
85 the same terms as Perl itself.
86  
87 =head1 AUTHOR
88  
89 Carl Franks <cpan@fireartist.com>
90  
91 =head1 COPYRIGHT AND LICENSE
92  
93 This software is copyright (c) 2018 by Carl Franks.
94  
95 This is free software; you can redistribute it and/or modify it under
96 the same terms as the Perl 5 programming language system itself.
97  
98 =cut
« lib/HTML/FormFu/Transformer/Callback.pm ↑ Summary lib/HTML/FormFu/I18N/bg.pm »