Neaf/X/Form/LIVR.pm

filter: Statementstmt 100% 16 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 100% 23 / 23 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Neaf/X.pm ↑ Summary
1 package MVC::Neaf::X::Form::LIVR;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 our $VERSION = '0.2901';
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<Validator::LIVR>.
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 ▶use parent qw(MVC::Neaf::X::Form);
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 =head2 new(\%profile)
26  
27 Receives a LIVR validation profile. See L<Validator::LIVR>.
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<Validator::LIVR> object.
36  
37 =cut
38  
39 1 ▶sub make_rules {
Subroutine make_rules: called CC=1 SCAR=0.0
Pod documented
40 1 my ($self, $rules) = @_;
41  
42 1 require Validator::LIVR;
43 1 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 3 ▶sub do_validate {
Subroutine do_validate: called CC=1 SCAR=0.0
Pod documented
53 3 my ($self, $data) = @_;
54  
55 return ( scalar $self->{rules}->validate( $data )
56 3 , $self->{rules}->get_errors );
57 };
58  
59 =head1 LICENSE AND COPYRIGHT
60  
61 This module is part of L<MVC::Neaf> suite.
62  
63 Copyright 2016-2023 Konstantin S. Uvarin C<khedin@cpan.org>.
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<http://dev.perl.org/licenses/> for more information.
70  
71 =cut
72  
73 2 1;
« Neaf/X.pm ↑ Summary