mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 19:52:54 +01:00
Added NonNegativeInteger.
This commit is contained in:
parent
b4f7b878cf
commit
a2feec9ac0
@ -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."""
|
||||||
|
Loading…
Reference in New Issue
Block a user