diff options
Diffstat (limited to 'src/mailman/rest/validator.py')
| -rw-r--r-- | src/mailman/rest/validator.py | 5 |
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: |
