code: def check_valid(money):
      
      if not isinstance(money, sc_messages.Money):
          raise ValueError(u'Inputs should be of type %s' % (sc_messages.Money,))
      currency = money.currencyCode
      if not currency or len(currency) != 3:
          raise ValueError(_MSG_3_LETTERS_LONG)
      units = money.units
      nanos = money.nanos
      if ((units > 0) and (nanos < 0)) or ((units < 0) and (nanos > 0)):
          raise ValueError(_MSG_UNITS_NANOS_MISMATCH)
      if abs(nanos) > MAX_NANOS:
          raise ValueError(_MSG_NANOS_OOB)
docs: Determine if an instance of `Money` is valid.
  
      Args:
        money (:class:`endpoints_management.gen.servicecontrol_v1_messages.Money`): the
          instance to test
  
      Raises:
        ValueError: if the money instance is invalid