code: def message(default=None, cls=None):
      
      if cls and not issubclass(cls, er.Invalid):
          raise er.SchemaError("message can only use subclases of Invalid as custom class")
  
      def decorator(f):
          @wraps(f)
          def check(msg=None, clsoverride=None):
              @wraps(f)
              def wrapper(*args, **kwargs):
                  try:
                      return f(*args, **kwargs)
                  except ValueError:
                      raise (clsoverride or cls or er.ValueInvalid)(msg or default or 'invalid value')
  
              return wrapper
  
          return check
  
      return decorator
docs: Convenience decorator to allow functions to provide a message.
  
      Set a default message:
  
          >>> @message('not an integer')
          ... def isint(v):
          ...   return int(v)
  
          >>> validate = Schema(isint())
          >>> with raises(er.MultipleInvalid, 'not an integer'):
          ...   validate('a')
  
      The message can be overridden on a per validator basis:
  
          >>> validate = Schema(isint('bad'))
          >>> with raises(er.MultipleInvalid, 'bad'):
          ...   validate('a')
  
      The class thrown too:
  
          >>> class IntegerInvalid(er.Invalid): pass
          >>> validate = Schema(isint('bad', clsoverride=IntegerInvalid))
          >>> try:
          ...  validate('a')
          ... except er.MultipleInvalid as e:
          ...   assert isinstance(e.errors[0], IntegerInvalid)