Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tutorius/constraints.py
diff options
context:
space:
mode:
authorisen <isen@isen-desktop.(none)>2009-10-05 23:39:19 (GMT)
committer isen <isen@isen-desktop.(none)>2009-10-05 23:39:19 (GMT)
commit94eed6bd64b048e6234b7bfccd0f4b39d3e955a3 (patch)
tree79e87ad3415130e857b02555b1051fd3c879af3a /tutorius/constraints.py
parentc7957e876fdc012af627f0cfacca019daffbbaad (diff)
TarrayOneType and TPositionProperty ok
Diffstat (limited to 'tutorius/constraints.py')
-rw-r--r--tutorius/constraints.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/tutorius/constraints.py b/tutorius/constraints.py
index f2e324f..455ede3 100644
--- a/tutorius/constraints.py
+++ b/tutorius/constraints.py
@@ -205,13 +205,21 @@ class FileConstraint(Constraint):
raise FileConstraintError("Non-existing file : %s"%value)
return
-class SameTypeConstraint(Exception):
+
+class SameTypeConstraintError(Exception):
pass
-class SameTypeConstraint(ValueConstraint):
- pass
- #def validate(self, typePropertie):
- # if self.limit != typePropertie:
- # raise SameTypeConstraint("Value with a diffferent type")
- #return
+class SameTypeConstraint(Constraint):
+ """
+ Ensures that the list is not empty and that properties of the list have the same type.
+ """
+
+ def validate(self, value):
+ if len(value)==0:
+ raise SameTypeConstraintError("The list is empty")
+ for i in value:
+ if i.type != value[0].type:
+ raise SameTypeConstraintError("Properties have diffferent type")
+ return
+