Skip to content

Commit

Permalink
Display valid Enum values in Coerce
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet authored Feb 15, 2022
1 parent 980a55f commit 7caa30b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions voluptuous/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ def __call__(self, v):
return self.type(v)
except (ValueError, TypeError, InvalidOperation):
msg = self.msg or ('expected %s' % self.type_name)
if not self.msg and issubclass(self.type, Enum):
msg += " or one of %s" % [e.value for e in self.type]
raise CoerceInvalid(msg)

def __repr__(self):
Expand Down

0 comments on commit 7caa30b

Please sign in to comment.