| 1 | package CGI::Application::Plugin::FormValidator::Simple; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use vars qw($VERSION @EXPORT); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use FormValidator::Simple; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | require Exporter; | |||||||||
| 9 | |||||||||||
| 10 | 1 | @EXPORT = qw( | |||||||||
| 11 | validator | ||||||||||
| 12 | form | ||||||||||
| 13 | ); | ||||||||||
| 14 | 1 | ▶ | sub import { goto &Exporter::import } | ||||||||
|
Subroutine
import: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 1 | $VERSION = '0.03'; | |||||||||
| 17 | |||||||||||
| 18 | 0 | ▶ | sub validator { | ||||||||
|
Subroutine
validator: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 19 | 0 | my $self = shift; | |||||||||
| 20 | 0 | my %params = @_; | |||||||||
| 21 | |||||||||||
| 22 | 0 | my $plugins = $params{plugins}; | |||||||||
| 23 | 0 | ▶ | FormValidator::Simple->import(@$plugins) if $plugins; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | |||||||||||
| 25 | 0 | my $options = $params{options}; | |||||||||
| 26 | 0 | $self->{validator} = FormValidator::Simple->new(%$options); | |||||||||
| 27 | |||||||||||
| 28 | 0 | ▶ | if (exists $params{messages}){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 0 | FormValidator::Simple->set_messages($params{messages}); | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | 0 | return $self->{validator}; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | |||||||||||
| 36 | 0 | ▶ | sub form { | ||||||||
|
Subroutine
form: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||
| 37 | 0 | my $self = shift; | |||||||||
| 38 | 0 | ▶ | if ($_[0]) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 0 | ▶ | my $form = $_[1] ? [@_] : $_[0]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 0 | ▶ | $self->validator() unless $self->{validator}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 0 | $self->{form} = $self->{validator}->check($self->query, $form); | |||||||||
| 42 | } | ||||||||||
| 43 | 0 | return $self->{form}; | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | |||||||||||
| 47 | 1 | 1; | |||||||||
| 48 | __END__ | ||||||||||