* Add enclair_db option to UserDB.pm. Allows logging of enclair password
[interchange.git] / code / OrderCheck / natural.oc
1 # Copyright 2005-2007 Interchange Development Group and others
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.  See the LICENSE file for details.
7
8 # $Id: natural.oc,v 1.4 2008-04-28 12:08:38 docelic Exp $
9
10 CodeDef natural OrderCheck
11 CodeDef natural Description Natural number
12 CodeDef natural Routine <<EOR
13 sub {
14         my ($ref, $name, $value, $code) = @_;
15
16         if ($value and $value > 0 and "$value" eq int($value)) {
17                 return (1, $name, '');
18         }
19
20         $code =~ s/\\/\\\\/g;
21         $code =~ s/^\s*(["'])(.+?)\1$/$2/;
22         
23         if ($code =~ /\S/) {
24                 return (0, $name, $code);
25         } else {
26                 return (0, $name, 'no natural number');
27         }
28 }
29 EOR
30