code: private boolean checkRequiredTag(IfdTags metadata, String tagName, int cardinality,
        long[] possibleValues) {
      boolean ok = true;
      int tagid = TiffTags.getTagId(tagName);
      if (!metadata.containsTagId(tagid)) {
        validation.addErrorLoc("Missing required tag for TiffIT" + profile + " " + tagName, "IFD"
            + currentIfd);
        ok = false;
      } else if (cardinality != -1 && metadata.get(tagid).getCardinality() != cardinality) {
        validation.addError("Invalid cardinality for TiffIT" + profile + " tag " + tagName, "IFD"
            + currentIfd,
            metadata.get(tagid)
            .getCardinality());
      } else if (cardinality == 1 && possibleValues != null) {
        long val = metadata.get(tagid).getFirstNumericValue();
        boolean contained = false;
        int i = 0;
        while (i < possibleValues.length && !contained) {
          contained = possibleValues[i] == val;
          i++;
        }
        if (!contained)
          validation.addError("Invalid value for TiffIT" + profile + " tag " + tagName, "IFD"
              + currentIfd, val);
      }
      return ok;
    }
docs: Check required tag is present, and its cardinality and value is correct.
  
  @param metadata the metadata
  @param tagName the name of the mandatory tag
  @param cardinality the mandatory cardinality
  @param possibleValues the possible tag values
  @return true, if tag is found