code: public void validateMetadata(IfdTags metadata) {
      int prevTagId = 0;
      try {
        TiffTags.getTiffTags();
      } catch (ReadTagsIOException e) {
      }
      for (TagValue ie : metadata.getTags()) {
        if (!TiffTags.tagMap.containsKey(ie.getId())) {
          validation.addWarning("Ignoring undefined tag id " + ie.getId(), "", "Metadata");
        } else if (!TiffTags.tagTypes.containsKey(ie.getType())) {
          validation.addWarning("Ignoring unknown tag type " + ie.getType(), "", "Metadata");
        }
        else {
          Tag t = TiffTags.getTag(ie.getId());
          String stype = TiffTags.tagTypes.get(ie.getType());
          if (ie.getId() == 320) {
            // Colormap length check
            long bps = 0;
            if (metadata.containsTagId(258))
              bps = metadata.get(258).getFirstNumericValue();
            long calc = 3 * (long) Math.pow(2, bps);
            if (calc != ie.getCardinality()) {
              validation.addError("Invalid cardinality for tag "
                  + TiffTags.getTag(ie.getId()).getName() + "[" + ie.getCardinality() + "]",
                  "Metadata", stype);
            }
          }
          try {
            // Cardinality check
            int card = Integer.parseInt(t.getCardinality());
            if (card != ie.getCardinality())
              validation.addError("Cardinality for tag " + TiffTags.getTag(ie.getId()).getName()
                  + " must be " + card, "Metadata",
                  ie.getCardinality());
          } catch (Exception e) {
            // TODO: Deal with formulas?
          }
        }
  
        if (ie.getId() < prevTagId) {
          if (tagOrderTolerance > 0)
            validation.addWarning("Tags are not in ascending order", "", "Metadata");
          else
            validation.addErrorLoc("Tags are not in ascending order", "Metadata");
        }
        prevTagId = ie.getId();
      }
    }
docs: Validates that the ifd entries have correct types and cardinalities, as they are defined in the
  JSONs tag configuration files.
  
  @param metadata the ifd metadata