Validates that the IFD conforms the Tiff/EP standard.
774575
@Override
  public void validate() {
    try {
      IFD ifd = model.getFirstIFD();
      int n = 0;
      while (ifd != null) {
        validateIfd(ifd, n);
        ifd = ifd.getNextIFD();
        n++;
      }
    } catch (Exception e) {

    }
  }
181969
def validate(self,
                 asset,
                 amount,
                 portfolio,
                 algo_datetime,
                 algo_current_data):
        
        # If the order is for 0 shares, then silently pass through.
        if amount == 0:
            return

        normalized_algo_dt = pd.Timestamp(algo_datetime).normalize()

        # Fail if the algo is before this Asset's start_date
        if asset.start_date:
            normalized_start = pd.Timestamp(asset.start_date).normalize()
            if normalized_algo_dt < normalized_start:
                metadata = {
                    'asset_start_date': normalized_start
                }
                self.handle_violation(
                    asset, amount, algo_datetime, metadata=metadata)
        # Fail if the algo has passed this Asset's end_date
        if asset.end_date:
            normalized_end = pd.Timestamp(asset.end_date).normalize()
            if normalized_algo_dt > normalized_end:
                metadata = {
                    'asset_end_date': normalized_end
                }
                self.handle_violation(
                    asset, amount, algo_datetime, metadata=metadata)
870917
function validateIODActions(IOD, IODOpts) {
		// Validate IOD action schema
		var actionErr = validateAction(IOD, IODOpts.action, IODOpts.params)
		if (actionErr) return actionErr

		// Validate IOD action required inputs
		var inputErr = validateActionInputs(IOD, IODOpts)
		if (inputErr) return inputErr

		// Validate IOD action parameter pairs
		var pairErr = validateParamPairs(IOD, IODOpts)
		if (pairErr) return pairErr
	}
776661
private void validateIfdSD(IFD ifd, int p) {
    IfdTags metadata = ifd.getMetadata();

    if (p == 2) {
      checkRequiredTag(metadata, "NewSubfileType", 1, new long[]{0});
    }
    checkRequiredTag(metadata, "ImageLength", 1);
    checkRequiredTag(metadata, "ImageWidth", 1);
    checkRequiredTag(metadata, "BitsPerSample", 1, new long[]{1});
    checkRequiredTag(metadata, "Compression", 1, new long[]{1,4,8});
    checkRequiredTag(metadata, "PhotometricInterpretation", 1, new long[] {5});
    checkRequiredTag(metadata, "StripOffsets", 1);
    if (p == 0) {
      checkRequiredTag(metadata, "Orientation", 1, new long[]{1,4,5,8});
    } else {
      checkRequiredTag(metadata, "Orientation", 1, new long[]{1});
    }
    if (p == 2) {
      checkRequiredTag(metadata, "SamplesPerPixel", 1, new long[]{1,4});
    }
    checkRequiredTag(metadata, "StripBYTECount", 1);
    checkRequiredTag(metadata, "XResolution", 1);
    checkRequiredTag(metadata, "YResolution", 1);
    checkRequiredTag(metadata, "PlanarConfiguration", 1, new long[]{2});
    if (p == 2) {
      checkRequiredTag(metadata, "ResolutionUnit", 1, new long[]{2, 3});
      checkRequiredTag(metadata, "NumberOfInks", 1, new long[]{4});
    }
    checkRequiredTag(metadata, "InkSet", 1, new long[]{1});
    checkRequiredTag(metadata, "BackgroundColorIndicator", 1, new long[]{0, 1, 2});
  }
1216063
def isValid( self ):
        
        check = nativestring(self._filepathEdit.text()).split(os.path.pathsep)[0]
        if ( self.filepathMode() == XFilepathEdit.Mode.SaveFile ):
            check = os.path.dirname(check)
        
        return os.path.exists(check)
1066781
def verify(path):
        """"""
        valid = False
        try:
            tf = SingleTifHolo._get_tif(path)
        except (ValueError, IsADirectoryError):
            pass
        else:
            if len(tf) == 1:
                valid = True
        return valid
1213155
private void validateBundleId(ResourceBundleDefinition definition) {
		String bundleId = definition.getBundleId();
		if (bundleId != null) {
			if (!bundleId.endsWith(fileExtension)) {
				throw new BundlingProcessException("The extension of the bundle " + definition.getBundleName() + " - "
						+ bundleId + " doesn't match the allowed extension : '" + fileExtension
						+ "'. Please update your bundle definition.");
			} else if (bundleId.startsWith(JawrConstant.WEB_INF_DIR_PREFIX)
					|| bundleId.startsWith(JawrConstant.META_INF_DIR_PREFIX)) {
				throw new BundlingProcessException("For the bundle " + definition.getBundleName() + ", the bundle id '"
						+ bundleId
						+ "' is not allowed because it starts with \"/WEB-INF/\". Please update your bundle definition.");
			}
		}
	}
1091434
public ValidationResult getTiffEPValidation() {
    TiffEPProfile bpep = new TiffEPProfile(tiffModel);
    bpep.validate();
    return bpep.getValidation();
  }
253370
protected function validateType () : bool
	{
		// Checks if video type is allowed
		if ($this->validateMimeType() == FALSE) return FALSE;
		// Checks if video size is valid for upload
		if ($this->validateFileSize() == FALSE) return FALSE;
		// Finally uplods the file after successful evaluation
		if ($this->uploadFile() == FALSE) return FALSE;

		return TRUE;
	}
199619
def _check_cell_validity(self, i, j):
        
        if i >= len(self._output):
            return True
        if j >= len(self._output[i]):
            return True
        if self._output[i][j] is None:
            return True
        return False
1307682
private void CheckStrips(IfdTags metadata, int n) {
    long offset;
    int id;

    // Strip offsets
    id = TiffTags.getTagId("StripOffsets");
    offset = metadata.get(id).getFirstNumericValue();
    int nso = metadata.get(id).getCardinality();
    if (offset <= 0)
      validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
          offset);

    // Strip Byte Counts
    id = TiffTags.getTagId("StripBYTECount");
    offset = metadata.get(id).getFirstNumericValue();
    int nsc = metadata.get(id).getCardinality();
    if (offset <= 0)
      validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
          offset);

    if (nso != nsc) {
      validation.addErrorLoc("Inconsistent strip lengths", "IFD" + n);
    }

    int pixelSize = 0;
    for (int i = 0; i < metadata.get("BitsPerSample").getCardinality(); i++) {
      pixelSize += metadata.get("BitsPerSample").getValue().get(i).toInt();
    }
    if (metadata.get("Compression").getFirstNumericValue() == 1
 && pixelSize >= 8) {
      int calculatedImageLength = 0;
      for (int i = 0; i < nsc; i++) {
        calculatedImageLength += metadata.get(id).getValue().get(i).toInt();
      }
      if (calculatedImageLength != metadata.get("ImageLength").getFirstNumericValue()
          * metadata.get("ImageWidth").getFirstNumericValue() * pixelSize / 8) {
        // validation.toString();
        validation.addErrorLoc("Calculated and declared image size do not match", "IFD" + n);
      }
    }

    // Rows per Strip
    id = TiffTags.getTagId("RowsPerStrip");
    if (!metadata.containsTagId(id)) {
      if (rowsPerStripTolerance > 0)
        validation.addWarning("Missing required field", TiffTags.getTag(id).getName(), "IFD" + n);
      else
        validation.addError("Missing required field", "IFD" + n, TiffTags.getTag(id).getName());
    } else {
      offset = metadata.get(id).getFirstNumericValue();
      if (offset <= 0)
        validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
            offset);
    }
  }
1316221
def _valid_file(self, base, name):
        """"""

        valid = False
        fullpath = os.path.join(base, name)
        if self.file_check is not None and self.compare_file(fullpath[self._base_len:] if self.file_pathname else name):
            valid = True
        if valid and (not self.show_hidden and util.is_hidden(fullpath)):
            valid = False
        return self.on_validate_file(base, name) if valid else valid
1325684
private boolean checkType(int tagid, int tagType, int n) {
    if (TiffTags.hasTag(tagid) && !TiffTags.getTag(tagid).getName().equals("IPTC")) {
      boolean found = false;
      String stagType = TiffTags.getTagTypeName(tagType);
      if (stagType != null) {
        if (stagType.equals("SUBIFD"))
          stagType = "IFD";
        if (stagType.equals("UNDEFINED"))
          stagType = "BYTE";
        for (String vType : TiffTags.getTag(tagid).getType()) {
          String vType2 = vType;
          if (vType2.equals("UNDEFINED"))
            vType2 = "BYTE";
          if (vType2.equals(stagType)) {
            found = true;
          }
        }
      }
      if (!found) {
        validation.addError("Incorrect type for tag " + TiffTags.getTag(tagid).getName(),
            "IFD" + n, stagType);
        return false;
      }
      return true;
    }
    return false;
  }
118160
def _validate(self, writing=False):
        """"""
        if ((len(self.bits_per_component) != len(self.signed)) or
                (len(self.signed) != self.palette.shape[1])):
            msg = ("The length of the 'bits_per_component' and the 'signed' "
                   "members must equal the number of columns of the palette.")
            self._dispatch_validation_error(msg, writing=writing)
        bps = self.bits_per_component
        if writing and not all(b == bps[0] for b in bps):
            # We don't support writing palettes with bit depths that are
            # different.
            msg = "Writing palettes with varying bit depths is not supported."
            self._dispatch_validation_error(msg, writing=writing)
192860
private void CheckRGBImage(IfdTags metadata, int n) {
    // Samples per Pixel
    long samples = metadata.get(TiffTags.getTagId("SamplesPerPixel")).getFirstNumericValue();
    if (samples < 3)
      validation.addError("Invalid Samples per Pixel", "IFD" + n, samples);

    // Compression
    long comp = metadata.get(TiffTags.getTagId("Compression")).getFirstNumericValue();
    // if (comp != 1 && comp != 32773)
    if (comp < 1)
      validation.addError("Invalid Compression", "IFD" + n, comp);
  }
209580
def isvalid(path, access=None, extensions=None, filetype=None, minsize=None):
    """"""
    return ((access is None or os.access(path, access)) and
            (extensions is None or checkext(path, extensions)) and
            (((filetype == 'all' and os.path.exists(path)) or
              (filetype == 'dir' and os.path.isdir(path)) or
              (filetype == 'file' and os.path.isfile(path))) or
             filetype is None) and
            (minsize is None or (not os.path.isfile(path) or
                                 os.path.getsize(path) > minsize)))
224694
private void CheckCommonFields(IFD ifd, int n, IfdTags metadata) {
    int id;

    // Width tag is mandatory
    id = TiffTags.getTagId("ImageWidth");
    if (!metadata.containsTagId(id))
      validation.addError("Missing required field", "IFD" + n, TiffTags.getTag(id).getName());
    else {
      long val = metadata.get(id).getFirstNumericValue();
      if (val <= 0)
        validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
            val);
    }

    // Height tag is mandatory
    id = TiffTags.getTagId("ImageLength");
    if (!metadata.containsTagId(id))
      validation.addError("Missing required field", "IFD" + n, TiffTags.getTag(id).getName());
    else {
      long val = metadata.get(id).getFirstNumericValue();
      if (val <= 0)
        validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
            val);
    }

    // Check Resolution Unit
    id = TiffTags.getTagId("ResolutionUnit");
    if (!metadata.containsTagId(id)) {
      // validation.addError("Missing required field", TiffTags.getTag(id).getName());
    } else {
      long val = metadata.get(id).getFirstNumericValue();
      if (val != 1 && val != 2 && val != 3)
        validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
            val);
    }

    // Check XResolution
    id = TiffTags.getTagId("XResolution");
    if (!metadata.containsTagId(id)) {
      // validation.addError("Missing required field", TiffTags.getTag(id).name);
    } else {
      float val = ((Rational) metadata.get(id).getValue().get(0)).getFloatValue();
      if (val <= 0f)
        validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
            val);
    }

    // Check YResolution
    id = TiffTags.getTagId("YResolution");
    if (!metadata.containsTagId(id)) {
      // validation.addError("Missing required field", TiffTags.getTag(id).name);
    } else {
      float val = ((Rational) metadata.get(id).getValue().get(0)).getFloatValue();
      if (val <= 0f)
        validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
            val);
    }

    // Check Planar Configuration
    id = TiffTags.getTagId("PlanarConfiguration");
    if (!metadata.containsTagId(id)) {
      // validation.addError("Missing required field", TiffTags.getTag(id).name);
    } else {
      long val = metadata.get(id).getFirstNumericValue();
      if (val != 1 && val != 2)
        validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
            val);
    }

    // Check Orientation
    id = TiffTags.getTagId("Orientation");
    if (!metadata.containsTagId(id)) {
      // validation.addError("Missing required field", TiffTags.getTag(id).name);
    } else {
      long val = metadata.get(id).getFirstNumericValue();
      if (val <= 0 || val > 8)
        validation.addError("Invalid value for field " + TiffTags.getTag(id).getName(), "IFD" + n,
            val);
    }

    // Check whether the image is stored in tiles or strips
    strips = ifd.hasStrips();
    tiles = ifd.hasTiles();
    if (!strips && !tiles) {
      validation.addErrorLoc("Missing image organization tags", "IFD" + n);
      validation.setFatalError(true, "Missing image organization tags");
    } else if (strips && tiles)
      validation.addErrorLoc("Image in both strips and tiles", "IFD" + n);
    else if (strips) {
      CheckStrips(metadata, n);
    } else if (tiles) {
      CheckTiles(ifd, metadata, n);
    }

    // Check pixel samples bits
    if (metadata.containsTagId(TiffTags.getTagId("BitsPerSample"))
        && metadata.containsTagId(TiffTags.getTagId("SampesPerPixel"))) {
      long spp = metadata.get(TiffTags.getTagId("SamplesPerPixel")).getFirstNumericValue();
      int bps = metadata.get(TiffTags.getTagId("BitsPerSample")).getValue().size();
      if (spp != bps) {
        validation
.addErrorLoc("Samples per Pixel and Bits per Sample count do not match", "IFD"
            + n);
        if (bps == 1) {
          // TODO: Tolerate and proceed as if the BitsPerSample tag had a count equal to the
          // SamplesPerPixel tag value, and with all values equal to the single value actually given
        }
      }

      if (metadata.containsTagId(TiffTags.getTagId("ExtraSamples"))) {
        int ext = metadata.get(TiffTags.getTagId("ExtraSamples")).getValue().size();
        if (ext + 3 != bps) {
          validation.addError("Incorrect Extra Samples Count", "IFD" + n, ext);
        } else if (ext > 0 && bps <= 3) {
          validation.addError("Unnecessary Extra Samples", "IFD" + n, ext);
        }
      }

      if (bps > 1) {
        TagValue lbps = metadata.get(TiffTags.getTagId("BitsPerSample"));
        if (lbps == null || lbps.getValue() == null) {
          validation.addErrorLoc("Invalid Bits per Sample", "IFD" + n);
        } else {
          boolean distinct_bps_samples = false;
          for (int i = 1; i < lbps.getCardinality(); i++) {
            if (lbps.getValue().get(i).toInt() != lbps.getValue().get(i - 1).toInt())
              distinct_bps_samples = true;
          }
          if (distinct_bps_samples)
            validation.addErrorLoc("Distinct Bits per Sample values", "IFD" + n);
        }
      }
    }
  }