from typing import Any
import numbers


def _has_valid_value(key: str, value: Any) -> bool:
  """Checks if the field has a usable value.

  A field should be ignored when the value has no actual data (e.g. numeric 0 is
  meaningful data but None is not meaningful).

  This method returns False if the given value is either of None, '', [] or {}.
  If the value is 0, False, or other values then it returns True.
  If the key is either "price" or "salePrice" and the dictionary values for
  "value" or "currency" are empty, it returns False.

  Args:
    key: The key of the given field.
    value: The value of given field.

  Returns:
    Whether the field should be ignored or not.
  """
  if key in ('price', 'salePrice'):
    if isinstance(value, dict) and value.get('currency') and value.get('value'):
      return True
    else:
      return False

  if value:
    return True
  elif isinstance(value, numbers.Number) or isinstance(value, bool):
    return True
  else:
    return False