[node-patches] Change in ovirt-node[master]: valid: Don't allow leading zeros for numbers

fabiand at fedoraproject.org fabiand at fedoraproject.org
Tue Dec 10 19:06:07 UTC 2013


Fabian Deutsch has uploaded a new change for review.

Change subject: valid: Don't allow leading zeros for numbers
......................................................................

valid: Don't allow leading zeros for numbers

Change-Id: Icd3500b2e4ae313ea84c1250aa3a490ae4e5baec
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=984343
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M src/ovirt/node/valid.py
1 file changed, 11 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/74/22274/1

diff --git a/src/ovirt/node/valid.py b/src/ovirt/node/valid.py
index 92ca35f..f3a5102 100644
--- a/src/ovirt/node/valid.py
+++ b/src/ovirt/node/valid.py
@@ -188,6 +188,14 @@
     True
     >>> Number()("42")
     True
+    >>> Number()("0")
+    True
+    >>> Number()("1")
+    True
+    >>> Number()(0)
+    True
+    >>> Number()("10")
+    True
     >>> Number(bounds=[0, None]).validate(-10)
     False
     >>> Number(bounds=[0, 10]).validate(11)
@@ -198,10 +206,12 @@
     True
     >>> Number(exactly=42).validate("4")
     False
+    >>> Number().validate("042")
+    False
     """
 
     description = "a number"
-    pattern = "^[-+]?\d+$"
+    pattern = "^[-+]?(0|[1-9]\d*)$"
     bounds = None
 
     def __init__(self, bounds=None, exactly=None):


-- 
To view, visit http://gerrit.ovirt.org/22274
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icd3500b2e4ae313ea84c1250aa3a490ae4e5baec
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>



More information about the node-patches mailing list