line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Form::Factory::Feature::Role::Check; |
2
|
|
|
|
|
|
|
$Form::Factory::Feature::Role::Check::VERSION = '0.022'; |
3
|
1
|
|
|
1
|
|
394
|
use Moose::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
requires qw( check ); |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: features that check control values |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
1; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__END__ |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=pod |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=encoding UTF-8 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Form::Factory::Feature::Role::Check - features that check control values |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 VERSION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
version 0.022 |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SYNOPSIS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
package MyApp::Feature::Bar; |
29
|
|
|
|
|
|
|
use Moose; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
with qw( |
32
|
|
|
|
|
|
|
Form::Factory::Feature |
33
|
|
|
|
|
|
|
Form::Factory::Feature::Role::Check |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub check { |
37
|
|
|
|
|
|
|
my $self = shift; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Check the value for errors, it must contain Bar |
40
|
|
|
|
|
|
|
my $value = $self->control->{something}->current_value; |
41
|
|
|
|
|
|
|
unless ($value =~ /\bBar\b/) { |
42
|
|
|
|
|
|
|
$self->result->error('control must contain Bar'); |
43
|
|
|
|
|
|
|
$self->result->is_valid(0); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
else { |
46
|
|
|
|
|
|
|
$self->result->is_valid(1); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
package Form::Factory::Feature::Custom::Bar; |
51
|
|
|
|
|
|
|
sub register_implementation { 'MyApp::Feature::Bar' } |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 DESCRIPTION |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Features that check the correctness of control values implement this role. This runs after input has been consumed and cleaned and before it is processed. The check here is meant to verify whether the input is valid and ready for processing. Mark the result as invalid to prevent processing. In general, it's a good idea to return an error if you do that. This is also a good place to return warnings. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 ROLE METHODS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 check |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
The check method is run after the data has been cleaned up and is intended for checking whether or not the data given is ready to be processed. A feature checking the input for valdation should set the C<is_valid> flag on the result. If you do not set C<is_valid>, then you will not influence whether or not the action is considered valid and ready to move on to the processing stage. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
This method is passed no arguments other than the object it is being called on. The return value is ignored. If you check method needs to output anything, it should do so through the attached C<result> object. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 AUTHOR |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Andrew Sterling Hanenkamp <hanenkamp@cpan.org> |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Qubling Software LLC. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
74
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |