Fix UUID validator implementation

- Document the new `flags` parameter now accepted by the Regex
  validator.
- Make use of the correct regex flag.
This commit is contained in:
Jimmy Thrasibule
2014-12-12 22:09:14 +01:00
parent 369e9dc2ef
commit 4420146652

View File

@@ -293,6 +293,9 @@ class Regex(object):
error message to be used; otherwise, defaults to 'String does
not match expected pattern'.
The ``regex`` expression behaviour can be modified by specifying
any ``flags`` value taken by ``re.compile``.
The ``regex`` argument may also be a pattern object (the
result of ``re.compile``) instead of a string.
@@ -467,7 +470,7 @@ url = Regex(URL_REGEX, _('Must be a URL'))
UUID_REGEX = r"""^(?:urn:uuid:)?\{?[a-f0-9]{8}(?:-?[a-f0-9]{4}){3}-?[a-f0-9]{12}\}?$"""
uuid = Regex(UUID_REGEX, _('Invalid UUID string'), 2) # 2 = re.IGNORECASE
uuid = Regex(UUID_REGEX, _('Invalid UUID string'), re.IGNORECASE)
class SchemaType(object):