code: private void validateEntities(JsonNode data) throws InvalidInputException {
      for (JsonNode node : data.findParents(INDEX_START)) {
  
        for (String key : new String[] {INDEX_START, INDEX_END, ID, TYPE}) {
          if (node.path(key).isMissingNode()) {
            throw new InvalidInputException("Required field \"" + key + "\" missing from the entity payload");
          }
        }
  
        int startIndex = node.get(INDEX_START).intValue();
        int endIndex = node.get(INDEX_END).intValue();
  
        if (endIndex <= startIndex) {
          throw new InvalidInputException(String.format("Invalid entity payload: %s (start index: %s, end index: %s)",
              node.get(ID).textValue(), startIndex, endIndex));
        }
  
      }
    }
docs: Verify that JSON entities contain the required fields and that entity indices are correct.