code: void validateFields(Iterable<Field> fields, List<Reserved> reserveds) {
      Multimap<Integer, Field> tagToField = LinkedHashMultimap.create();
      Multimap<String, Field> nameToField = LinkedHashMultimap.create();
      for (Field field : fields) {
        int tag = field.tag();
        if (!Util.isValidTag(tag)) {
          withContext(field).addError("tag is out of range: %s", tag);
        }
  
        for (Reserved reserved : reserveds) {
          if (reserved.matchesTag(tag)) {
            withContext(field).addError("tag %s is reserved (%s)", tag, reserved.getLocation());
          }
          if (reserved.matchesName(field.name())) {
            withContext(field).addError("name '%s' is reserved (%s)", field.name(),
                reserved.getLocation());
          }
        }
  
        tagToField.put(tag, field);
        nameToField.put(field.qualifiedName(), field);
      }
  
      for (Map.Entry<Integer, Collection<Field>> entry : tagToField.asMap().entrySet()) {
        if (entry.getValue().size() > 1) {
          StringBuilder error = new StringBuilder();
          error.append(String.format("multiple fields share tag %s:", entry.getKey()));
          int index = 1;
          for (Field field : entry.getValue()) {
            error.append(String.format("\n  %s. %s (%s)",
                index++, field.name(), field.location()));
          }
          addError("%s", error);
        }
      }
  
      for (Collection<Field> collidingFields : nameToField.asMap().values()) {
        if (collidingFields.size() > 1) {
          Field first = collidingFields.iterator().next();
          StringBuilder error = new StringBuilder();
          error.append(String.format("multiple fields share name %s:", first.name()));
          int index = 1;
          for (Field field : collidingFields) {
            error.append(String.format("\n  %s. %s (%s)",
                index++, field.name(), field.location()));
          }
          addError("%s", error);
        }
      }
    }
docs: Validate that the tags of {@code fields} are unique and in range.