code: def _validate_max_staleness(max_staleness):
      
      if max_staleness == -1:
          return -1
  
      if not isinstance(max_staleness, integer_types):
          raise TypeError(_invalid_max_staleness_msg(max_staleness))
  
      if max_staleness <= 0:
          raise ValueError(_invalid_max_staleness_msg(max_staleness))
  
      return max_staleness
docs: Validate max_staleness.