diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-03 18:32:49 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-03 18:32:49 +0000 |
commit | 085ea3f62f37539a279f7d4ade51208fcbe868b9 (patch) | |
tree | 18029cb9fd5360ea9a088585c1a37b6bda474297 /ipalib/ipa_types.py | |
parent | baef0e6f49aaf75c3d71e3afd9cf2a2abcb07152 (diff) | |
download | freeipa-085ea3f62f37539a279f7d4ade51208fcbe868b9.tar.gz freeipa-085ea3f62f37539a279f7d4ade51208fcbe868b9.tar.xz freeipa-085ea3f62f37539a279f7d4ade51208fcbe868b9.zip |
239: Added errors.ConversionError; started big clean up of how ValidationError is raised so it works well with multivalues
Diffstat (limited to 'ipalib/ipa_types.py')
-rw-r--r-- | ipalib/ipa_types.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/ipalib/ipa_types.py b/ipalib/ipa_types.py index c120b5abf..2da8e0be8 100644 --- a/ipalib/ipa_types.py +++ b/ipalib/ipa_types.py @@ -58,6 +58,9 @@ class Type(ReadOnly): if type_ not in allowed: raise ValueError('not an allowed type: %r' % type_) self.type = type_ + # FIXME: This should be replaced with a more user friendly message + # as this is what is returned to the user. + self.conversion_error = 'Must be a %r' % self.type lock(self) def __get_name(self): @@ -73,6 +76,9 @@ class Type(ReadOnly): except (TypeError, ValueError): return None + def validate(self, value): + pass + def __call__(self, value): if value is None: raise TypeError('value cannot be None') @@ -102,10 +108,6 @@ class Bool(Type): return False return None - def validate(self, value): - if not (value is True or value is False): - return 'Must be %r or %r' % (self.true, self.false) - class Int(Type): def __init__(self, min_value=None, max_value=None): |