docs: def filter_decimal(string, default=None, lower=None, upper=None):
      """Return the input decimal number, or the default."""
      try:
          d = decimal.Decimal(string)
          if lower is not None and d < lower:
              raise InvalidInputError("value too small")
          if upper is not None and d >= upper:
              raise InvalidInputError("value too large")
          return d
      except decimal.InvalidOperation:
          if not string and default is not None:
              # empty string, default was given
              return default
          else:
              raise InvalidInputError("invalid decimal number")