Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Interchange: cvs
[interchange] Rename numeric ordercheck to numeric_strict, and add laxer numeric check
 

Index | Next | Previous | View Flat


interchange-cvs at icdevgroup

Apr 7, 2010, 1:40 PM


Views: 283
Permalink
[interchange] Rename numeric ordercheck to numeric_strict, and add laxer numeric check

commit 5e03d9ebceeecd1726fd8db77c580cfc660f569c
Author: Jon Jensen <jon [at] endpoint>
Date: Wed Apr 7 14:38:39 2010 -0600

Rename numeric ordercheck to numeric_strict, and add laxer numeric check

code/OrderCheck/numeric.oc | 4 +++-
code/OrderCheck/numeric_strict.oc | 21 +++++++++++++++++++++
2 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/code/OrderCheck/numeric.oc b/code/OrderCheck/numeric.oc
index 4267c4b..c44b1c4 100644
--- a/code/OrderCheck/numeric.oc
+++ b/code/OrderCheck/numeric.oc
@@ -8,10 +8,12 @@
CodeDef numeric OrderCheck
CodeDef numeric Description Numeric
CodeDef numeric Routine <<EOR
+
sub {
my ($ref, $name, $value, $msg) = @_;
+ use Scalar::Util qw/looks_like_number/;

- if (defined($value) and $value =~ /\A-?\d+(\.\d+)?\z/) {
+ if (looks_like_number($value)) {
return (1, $name, '');
}
else {
diff --git a/code/OrderCheck/numeric_strict.oc b/code/OrderCheck/numeric_strict.oc
new file mode 100644
index 0000000..0a6b1d1
--- /dev/null
+++ b/code/OrderCheck/numeric_strict.oc
@@ -0,0 +1,21 @@
+# Copyright 2010 Interchange Development Group and others
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version. See the LICENSE file for details.
+
+CodeDef numeric_strict OrderCheck
+CodeDef numeric_strict Description Numeric (strict)
+CodeDef numeric_strict Routine <<EOR
+sub {
+ my ($ref, $name, $value, $msg) = @_;
+
+ if (defined($value) and $value =~ /\A-?\d+(?:\.\d+)?\z/) {
+ return (1, $name, '');
+ }
+ else {
+ return (0, $name, defined($msg) ? $msg : 'not strict numeric');
+ }
+}
+EOR

_______________________________________________
interchange-cvs mailing list
interchange-cvs [at] icdevgroup
http://www.icdevgroup.org/mailman/listinfo/interchange-cvs

Subject User Time
[interchange] Rename numeric ordercheck to numeric_strict, and add laxer numeric check interchange-cvs at icdevgroup Apr 7, 2010, 1:40 PM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.