Added NonNegativeInteger.

This commit is contained in:
Jeremy Fincher 2004-07-31 12:09:52 +00:00
parent b4f7b878cf
commit a2feec9ac0

View File

@ -299,18 +299,19 @@ class Integer(Value):
except ValueError: except ValueError:
self.error() self.error()
class PositiveInteger(Value): class PositiveInteger(Integer):
"""Value must be positive (non-zero) integer.""" """Value must be positive (non-zero) integer."""
def set(self, s):
try:
self.setValue(int(s))
except ValueError:
self.error()
def setValue(self, v): def setValue(self, v):
if v <= 0: if v <= 0:
self.error() self.error()
Value.setValue(self, v) Integer.setValue(self, v)
class NonNegativeInteger(Integer):
"""Value must not be negative."""
def setValue(self, v):
if v < 0:
self.error()
Integer.setValue(self, v)
class Float(Value): class Float(Value):
"""Value must be a floating-point number.""" """Value must be a floating-point number."""