line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SparkX::Form::Field::Validator::NotEmpty; |
2
|
|
|
|
|
|
|
our $VERSION = '0.2102'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: Validates a field has some value |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
501
|
use Moose::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has errmsg_empty => ( |
10
|
|
|
|
|
|
|
isa => 'Str', |
11
|
|
|
|
|
|
|
is => 'rw', |
12
|
|
|
|
|
|
|
required => 0, |
13
|
|
|
|
|
|
|
default => sub { |
14
|
|
|
|
|
|
|
my $self = shift; |
15
|
|
|
|
|
|
|
return $self->human_name . |
16
|
|
|
|
|
|
|
' must be provided.' |
17
|
|
|
|
|
|
|
}, |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _not_empty { |
21
|
3
|
|
|
3
|
|
4
|
my ($self) = @_; |
22
|
|
|
|
|
|
|
|
23
|
3
|
100
|
|
|
|
60
|
unless ($self->value) { |
24
|
2
|
|
|
|
|
52
|
$self->error($self->errmsg_empty); |
25
|
|
|
|
|
|
|
} |
26
|
3
|
|
|
|
|
6
|
return $self; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
after '_validate' => sub { return shift->_not_empty }; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=pod |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 NAME |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
SparkX::Form::Field::Validator::NotEmpty - Validates a field has some value |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 VERSION |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
version 0.2102 |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 DESCRIPTION |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
A not empty enforcement mix-in. Adds one field plus action. |
48
|
|
|
|
|
|
|
Makes sure that C<value> is not empty. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 ACCESSORS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 errmsg_empty => Str |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Error message to be shown to the user if C<value> is empty. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 AUTHOR |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
James Laver L<http://jameslaver.com> |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
This software is copyright (c) 2009 by James Laver C<< <sprintf qw(%s@%s.%s cpan jameslaver com)> >>. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
67
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |
74
|
|
|
|
|
|
|
|