Debian Codegraph @

Embperl/Form/Validate/Integer.pm

raw
1
2 ###################################################################################
3 #
4 # Embperl - Copyright (c) 1997-2008 Gerald Richter / ecos gmbh www.ecos.de
5 # Embperl - Copyright (c) 2008-2014 Gerald Richter
6 #
7 # You may distribute under the terms of either the GNU General Public
8 # License or the Artistic License, as specified in the Perl README file.
9 #
10 # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
11 # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
12 # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 #
14 # $Id: Integer.pm 1578075 2014-03-16 14:01:14Z richter $
15 #
16 ###################################################################################
17
18
19 package Embperl::Form::Validate::Integer ;
20
21 use base qw(Embperl::Form::Validate::Number);
22
23
24 # --------------------------------------------------------------
25
26 sub validate
27 {
28 my ($self, $key, $value, $fdat, $pref) = @_ ;
29
30 return $value =~ /^\s*[0-9+-][0-9]*\s*$/ ? undef : ['validate_number', $value] ;
31 }
32
33 # --------------------------------------------------------------
34
35 sub getscript_validate
36 {
37 my ($self, $arg, $pref) = @_ ;
38
39 return ('obj.value.search(/^\s*[0-9+-][0-9]*\s*$/) >= 0', ['validate_number', "'+obj.value+'"]) ;
40 }
41
42
43
44 1;