| 1 | package CGI::Application::CheckRM ; | ||
| 2 | $VERSION = 1.21 ; | ||
| 3 | 1 | ▶ | use strict ; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | # This file uses the "Perlish" coding style | ||
| 6 | # please read http://perl.4pro.net/perlish_coding_style.html | ||
| 7 | |||
| 8 | ; use Carp | ||
| 9 | 1 | ▶ | ; use Data::FormValidator |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 0 | ▶ | ; use Object::props |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 12 | ( { name => 'dfv_results' | ||
| 13 | , allowed => qr /::checkRM$/ | ||
| 14 | } | ||
| 15 | ) | ||
| 16 | |||
| 17 | ; use Object::groups | ||
| 18 | ( { name => 'dfv_defaults' | ||
| 19 | , no_strict => 1 | ||
| 20 | } | ||
| 21 | ) | ||
| 22 | |||
| 23 | ; sub checkRM | ||
| 24 | { my $s = shift | ||
| 25 | ; my $profile = shift || croak 'Missing required profile' | ||
| 26 | ; $profile = do | ||
| 27 | { ref $profile eq 'HASH' && $profile | ||
| 28 | || $s->can($profile) && $s->$profile() | ||
| 29 | || eval { $s->$profile() } | ||
| 30 | } | ||
| 31 | ; $@ && croak qq(Error running profile method "$profile": $@) | ||
| 32 | ; my $dfv = Data::FormValidator | ||
| 33 | ->new( {} | ||
| 34 | , scalar $s->dfv_defaults | ||
| 35 | ) | ||
| 36 | ; my $r = $dfv->check( $s->query | ||
| 37 | , $profile | ||
| 38 | ) | ||
| 39 | ; if ( $r->has_missing | ||
| 40 | || $r->has_invalid | ||
| 41 | ) | ||
| 42 | { $^W && carp qq(Input error detected for run-mode "$$s{runmode}") | ||
| 43 | ; $s->dfv_results = $r | ||
| 44 | ; return 0 | ||
| 45 | } | ||
| 46 | else | ||
| 47 | { return 1 | ||
| 48 | } | ||
| 49 | } | ||
| 50 | |||
| 51 | ; 1 | ||
| 52 | |||
| 53 | __END__ | ||