diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-27 22:26:35 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-27 22:26:35 +0000 |
commit | 2984041d00f509b34a6ba7f0f0f79135ba6842a3 (patch) | |
tree | f0c4d47fa09fd1a3877e0c07c8459804b6e35743 /ipalib/ipa_types.py | |
parent | e6cecfdcf299db564a9055ad69b1c0bc75d4af31 (diff) | |
download | freeipa-2984041d00f509b34a6ba7f0f0f79135ba6842a3.tar.gz freeipa-2984041d00f509b34a6ba7f0f0f79135ba6842a3.tar.xz freeipa-2984041d00f509b34a6ba7f0f0f79135ba6842a3.zip |
205: Continued work on Unicode.__init__() and corresponding unit tests
Diffstat (limited to 'ipalib/ipa_types.py')
-rw-r--r-- | ipalib/ipa_types.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/ipalib/ipa_types.py b/ipalib/ipa_types.py index d94a44fc2..f0baf1ba6 100644 --- a/ipalib/ipa_types.py +++ b/ipalib/ipa_types.py @@ -83,11 +83,15 @@ class Int(Type): class Unicode(Type): - def __init__(self, length=None,min_length=None, max_length=None, pattern=None): + def __init__(self, min_length=None, max_length=None, pattern=None): check_min_max(min_length, max_length, 'min_length', 'max_length') if min_length is not None and min_length < 0: - raise ValueError( - 'min_length must zero or greater, got: %r' % min_length + raise ValueError('min_length must be >= 0, got: %r' % min_length) + if max_length is not None and max_length < 1: + raise ValueError('max_length must be >= 1, got: %r' % max_length) + if not (pattern is None or isinstance(pattern, basestring)): + raise TypeError( + 'pattern must be a basestring or None, got: %r' % pattern ) self.min_length = min_length self.max_length = max_length |