code: def ValidateAndReturnIntValue(value, allowed_values, default, allow_empty,
                                column_name=None, problems=None):
    
    if allow_empty and IsEmpty(value):
      return default
    try:
      int_value = int(value)
    except (ValueError, TypeError):
      if problems and column_name:
        problems.InvalidValue(column_name, value)
      return default
    else:
      if int_value not in allowed_values:
        if problems and column_name:
          problems.InvalidValue(column_name, value,
                                type=errors.TYPE_WARNING)
      return int_value
docs: Validates a value to be a valid integer in the list of allowed values:
      - if no integer value adds InvalidValue error and returns the default value
      - if integer but not in allowed_values addes InvalidValue warning
      - returns the default value if empty and allow_empty = True
  
    Args:
      value: a string or integer value
      allowed_values: a list of allowed integer values
      default: a default value for invalid string vlaues
      allow_empty: a bool indicating whether an empty value is allowed and
                   defaults to the default value
      column_name: the column name the value comes from
      problems: the problems accumulator
  
    Returns:
      An integer value.