summaryrefslogtreecommitdiff
path: root/src/mailman/rest/validator.py
diff options
context:
space:
mode:
authorAurélien Bompard2016-06-10 19:55:25 +0200
committerBarry Warsaw2016-07-12 19:06:19 -0400
commitfdc9519917a7977e73225e3e5a66e2f0538e592c (patch)
treeb04f510f56a3e96fad6e4a62e606ed5f9f7a61f1 /src/mailman/rest/validator.py
parent0e37e111c1d2e83d37743d124628e65eb56a8b5a (diff)
downloadmailman-fdc9519917a7977e73225e3e5a66e2f0538e592c.tar.gz
mailman-fdc9519917a7977e73225e3e5a66e2f0538e592c.tar.zst
mailman-fdc9519917a7977e73225e3e5a66e2f0538e592c.zip
Diffstat (limited to 'src/mailman/rest/validator.py')
-rw-r--r--src/mailman/rest/validator.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/mailman/rest/validator.py b/src/mailman/rest/validator.py
index 861b869de..0a6184850 100644
--- a/src/mailman/rest/validator.py
+++ b/src/mailman/rest/validator.py
@@ -52,12 +52,15 @@ class ReadOnlyPATCHRequestError(RESTError):
class enum_validator:
"""Convert an enum value name into an enum value."""
- def __init__(self, enum_class):
+ def __init__(self, enum_class, allow_none=False):
self._enum_class = enum_class
+ self._allow_none = allow_none
def __call__(self, enum_value):
# This will raise a KeyError if the enum value is unknown. The
# Validator API requires turning this into a ValueError.
+ if self._allow_none and not enum_value:
+ return None
try:
return self._enum_class[enum_value]
except KeyError as exception: