[Zope3-checkins] CVS: Zope3/src/zope/schema - _bootstrapinterfaces.py:1.3

Stephan Richter srichter at cosmos.phy.tufts.edu
Sun Apr 11 06:35:09 EDT 2004


Update of /cvs-repository/Zope3/src/zope/schema
In directory cvs.zope.org:/tmp/cvs-serv4878/src/zope/schema

Modified Files:
	_bootstrapinterfaces.py 
Log Message:


Added method 'doc()' to ValidationError that returns a string for user output.



Created a bunch of validation error classes.




=== Zope3/src/zope/schema/_bootstrapinterfaces.py 1.2 => 1.3 ===
--- Zope3/src/zope/schema/_bootstrapinterfaces.py:1.2	Mon Dec  1 11:19:44 2003
+++ Zope3/src/zope/schema/_bootstrapinterfaces.py	Sun Apr 11 06:35:08 2004
@@ -17,6 +17,8 @@
 """
 import zope.interface
 
+from zope.i18nmessageid import MessageIDFactory
+_ = MessageIDFactory("zope")
 
 class StopValidation(Exception):
     """Raised if the validation is completed early.
@@ -25,15 +27,48 @@
     a way for the validator to save time.
     """
 
-
 class ValidationError(zope.interface.Invalid):
     """Raised if the Validation process fails."""
 
+    def doc(self):
+        return self.__class__.__doc__
+
     def __cmp__(self, other):
         return cmp(self.args, other.args)
 
     def __repr__(self):
         return ' '.join(map(str, self.args))
+
+class RequiredMissing(ValidationError):
+    __doc__ = _("""Required input is missing.""")
+
+class WrongType(ValidationError):
+    __doc__ = _("""Object is of wrong type.""")
+
+class TooBig(ValidationError):
+    __doc__ = _("""Value is too big""")
+
+class TooSmall(ValidationError):
+    __doc__ = _("""Value is too small""")
+
+class TooLong(ValidationError):
+    __doc__ = _("""Value is too long""")
+
+class TooShort(ValidationError):
+    __doc__ = _("""Value is too short""")
+
+class InvalidValue(ValidationError):
+    __doc__ = _("""Invalid value""")
+
+class ConstraintNotSatisfied(ValidationError):
+    __doc__ = _("""Constraint not satisfied""")
+
+class NotAContainer(ValidationError):
+    __doc__ = _("""Not a container""")
+
+class NotAnIterator(ValidationError):
+    __doc__ = _("""Not an iterator""")
+
 
 class IFromUnicode(zope.interface.Interface):
     """Parse a unicode string to a value




More information about the Zope3-Checkins mailing list