| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package SparkX::Form::Field::Validator::Confirm; |
|
2
|
|
|
|
|
|
|
our $VERSION = '0.2102'; |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: Validates whether or not the user confirmed some choice. |
|
6
|
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
1002
|
use Moose::Role; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has confirm => ( |
|
10
|
|
|
|
|
|
|
isa => 'Maybe[Str]', |
|
11
|
|
|
|
|
|
|
is => 'rw', |
|
12
|
|
|
|
|
|
|
required => 0, |
|
13
|
|
|
|
|
|
|
lazy => 1, |
|
14
|
|
|
|
|
|
|
default => undef, |
|
15
|
|
|
|
|
|
|
); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has errmsg_confirm => ( |
|
18
|
|
|
|
|
|
|
isa => 'Str', |
|
19
|
|
|
|
|
|
|
is => 'rw', |
|
20
|
|
|
|
|
|
|
required => 0, |
|
21
|
|
|
|
|
|
|
lazy => 1, |
|
22
|
|
|
|
|
|
|
default => sub { |
|
23
|
|
|
|
|
|
|
my $self = shift; |
|
24
|
|
|
|
|
|
|
return $self->human_name . |
|
25
|
|
|
|
|
|
|
' must match ' . |
|
26
|
|
|
|
|
|
|
$self->_confirm_human_name |
|
27
|
|
|
|
|
|
|
}, |
|
28
|
|
|
|
|
|
|
); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _confirm_field { |
|
31
|
7
|
|
|
7
|
|
8
|
my ($self) = @_; |
|
32
|
|
|
|
|
|
|
|
|
33
|
7
|
|
|
|
|
178
|
return $self->form->get($self->confirm); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _confirm_human_name { |
|
37
|
1
|
|
|
1
|
|
2
|
my ($self) = @_; |
|
38
|
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
2
|
return $self->_confirm_field->human_name; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _confirm { |
|
43
|
6
|
|
|
6
|
|
6
|
my ($self) = @_; |
|
44
|
|
|
|
|
|
|
|
|
45
|
6
|
50
|
|
|
|
200
|
return unless $self->confirm; |
|
46
|
|
|
|
|
|
|
|
|
47
|
6
|
100
|
|
|
|
159
|
if ($self->value ne $self->_confirm_field->value) { |
|
48
|
1
|
|
|
|
|
25
|
$self->error($self->errmsg_confirm); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
6
|
|
|
|
|
16
|
return $self; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
after '_validate' => sub { return shift->_confirm }; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=pod |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 NAME |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
SparkX::Form::Field::Validator::Confirm - Validates whether or not the user confirmed some choice. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 VERSION |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
version 0.2102 |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
A confirmation comparison mix-in. Adds two fields plus action. |
|
73
|
|
|
|
|
|
|
Makes sure that the selected C<confirm> field matches this one. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 ACCESSORS |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 confirm => Str |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Name of the field whose value must match. |
|
80
|
|
|
|
|
|
|
Required, no default. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 errmsg_confirm => Str |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Allows you to provide a custom error message for when the fields do not match. |
|
85
|
|
|
|
|
|
|
Optional, Default = $human_name must match $confirm_human_name |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 AUTHOR |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
James Laver L<http://jameslaver.com> |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This software is copyright (c) 2009 by James Laver C<< <sprintf qw(%s@%s.%s cpan jameslaver com)> >>. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
98
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |
|
105
|
|
|
|
|
|
|
|