diff --git a/tailbone/forms/widgets.py b/tailbone/forms/widgets.py index 7c89fa7d..b90f9dda 100644 --- a/tailbone/forms/widgets.py +++ b/tailbone/forms/widgets.py @@ -79,7 +79,10 @@ class PercentInputWidget(dfwidget.TextInputWidget): if pstruct is colander.null: return colander.null # convert "human-friendly" value to "traditional" - value = decimal.Decimal(pstruct) + try: + value = decimal.Decimal(pstruct) + except decimal.InvalidOperation: + raise colander.Invalid(field.schema, "Invalid decimal string: {}".format(pstruct)) value = value.quantize(decimal.Decimal('0.00001')) value /= 100 return six.text_type(value)