line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MVC::Neaf::X::Form::LIVR; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
161496
|
use strict; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
65
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
99
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.2800_01'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
MVC::Neaf::X::Form::LIVR - LIVR-based form validator for Not Even A Framework. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Do input validation using L. |
14
|
|
|
|
|
|
|
Return an object with is_valid(), data(), error(), and raw() methods. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 METHODS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Don't require LIVR so far as it may be absent on client machine. |
21
|
|
|
|
|
|
|
# Wait until we REALLY need it. |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
2
|
|
13
|
use parent qw(MVC::Neaf::X::Form); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
17
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 new(\%profile) |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Receives a LIVR validation profile. See L. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Additional options MAY be added later. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 make_rules(\%profile) |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Pre-process the rules. Returns a L object. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub make_rules { |
40
|
1
|
|
|
1
|
1
|
3
|
my ($self, $rules) = @_; |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
6
|
require Validator::LIVR; |
43
|
1
|
|
|
|
|
5
|
return Validator::LIVR->new( $rules ); |
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 do_validate( $data ) |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Actually validate the data. Returns clean data and errors generated by LIVR. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub do_validate { |
53
|
3
|
|
|
3
|
1
|
7
|
my ($self, $data) = @_; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
return ( scalar $self->{rules}->validate( $data ) |
56
|
3
|
|
|
|
|
8
|
, $self->{rules}->get_errors ); |
57
|
|
|
|
|
|
|
}; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
This module is part of L suite. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Copyright 2016-2023 Konstantin S. Uvarin C. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
66
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
67
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
See L for more information. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |