Validate the box before writing to file.
353573
def _validate(self, writing=False):
        
        if self.brand not in ['jp2 ', 'jpx ']:
            msg = ("The file type brand was '{brand}'.  "
                   "It should be either 'jp2 ' or 'jpx '.")
            msg = msg.format(brand=self.brand)
            if writing:
                raise IOError(msg)
            else:
                warnings.warn(msg, UserWarning)
        for item in self.compatibility_list:
            if item not in self._valid_cls:
                msg = ("The file type compatibility list {items} is "
                       "not valid.  All items should be members of "
                       "{valid_entries}.")
                msg = msg.format(items=self.compatibility_list,
                                 valid_entries=self._valid_cls)
                if writing:
                    raise IOError(msg)
                else:
                    warnings.warn(msg, UserWarning)
52502
def validate_for_request(self):
        """"""
        if not self.use_packages and not self.modules and not self.pulp:
            raise ValueError("Nothing to compose (no packages, modules, or enabled pulp repos)")

        if self.packages and not self.koji_tag:
            raise ValueError('koji_tag is required when packages are used')
424899
def validate(self, path):
        """"""
        # Exclude hidden files and folders with '.' prefix
        if os.path.basename(path).startswith('.'):
            return False

        # Check that current path level is more than min path and less than max path
        if not self.check_level(path):
            return False

        if self.filters:
            if not self._level_filters(path):
                return False

        # Force include and exclude iterations to be strings in case of integer filters
        # Handle exclusions
        if self.to_exclude:
            if any(str(ex).lower() in path.lower() for ex in self.to_exclude):
                return False

        # Handle inclusions
        if self.to_include:
            if not any(str(inc).lower() in path.lower() for inc in self.to_include):
                return False

        return True
638285
private function _validate()
	{
		$this->checkOverwritePermission();
		$this->checkHasValidUploadDirectory();
		$this->checkFileSize();
		$this->checkFileTypeIsAllowed();
		$this->checkFileTypeIsNotBlocked();

		return true;
	}
1374522
function validate(boxes, box) {
	var a = box
	for (var i = 0; i < boxes.length; i++) {
		var b = boxes[i]
		if (intersects(a, b)) {
			return false
		}
	}
	return true
}
438402
function validate(flags) {
  if (!flags) return false;

  if (flags.binary)
    throw new Error('binary stream not supported');

  if (flags.masked)
    throw new Error('masked stream not supported');

  return true;
}
637306
def _validate(self, writing=False):
        """"""
        box_ids = [box.box_id for box in self.box]
        if len(box_ids) != 1 or box_ids[0] != 'flst':
            msg = ("Fragment table boxes must have a single fragment list "
                   "box as a child box.")
            self._dispatch_validation_error(msg, writing=writing)
695419
def validate(self):
        
        if not self.file.exists():
            raise ValueError("File \"%s\" doesn't exists")

        if not self.search:
            raise ValueError("Search cannot be empty")

        if not self.replace:
            raise ValueError("Replace cannot be empty")

        if self.match not in ('file', 'line'):
            raise ValueError("Match must be one of: file, line")

        try:
            codecs.lookup(self.encoding)
        except LookupError:
            raise ValueError("Unknown encoding: \"%s\"" % self.encoding)
1344704
public void validateFileDoesNotExist(UIInput<String> directory, UIInput<String> fileName, UIValidationContext validator) {
        String resourcePath = CamelXmlHelper.createFileName(directory, fileName);
        if (files.contains(resourcePath)) {
            validator.addValidationError(fileName, "A file with that name already exists!");
        }
    }
625721
def is_valid(self):
        """"""
        for lineedit in self.lineedits:
            if lineedit in self.validate_data and lineedit.isEnabled():
                validator, invalid_msg = self.validate_data[lineedit]
                text = to_text_string(lineedit.text())
                if not validator(text):
                    QMessageBox.critical(self, self.get_name(),
                                     "%s:<br><b>%s</b>" % (invalid_msg, text),
                                     QMessageBox.Ok)
                    return False
        return True
1164975
protected function validateFileExport()
    {
        $directory = gplcart_file_private_module('export');

        if (!file_exists($directory) && !mkdir($directory, 0775, true)) {
            $this->setError('file', $this->text('Unable to create @name', array('@name' => $directory)));
            return false;
        }

        $date = date('d-m-Y--H-i');
        $file = gplcart_file_unique("$directory/$date.csv");

        if (file_put_contents($file, '') === false) {
            $this->setError('file', $this->text('Unable to create @name', array('@name' => $file)));
            return false;
        }

        $this->setSubmitted('file', $file);
        return true;
    }
1092253
def _validate_item(self, item):
        """"""
        if not isinstance(item, six.string_types):
            raise ValidationError(
                self._record,
                "Text list field items must be strings, not '{}'".format(item.__class__)
            )

        words = item.split(' ')

        item_length_type = self._field.field_definition.get('itemLengthType')
        item_max_length = self._field.field_definition.get('itemMaxLength')
        item_min_length = self._field.field_definition.get('itemMinLength')
        if item_length_type is not None:
            # Min/max word count
            if item_length_type == 'words':
                if item_max_length is not None:
                    if len(words) > item_max_length:
                        raise ValidationError(
                            self._record,
                            "Field '{}' items cannot contain more than {} words".format(
                                self._field.name,
                                item_max_length
                            )
                        )
                if item_min_length is not None:
                    if len(words) < item_min_length:
                        raise ValidationError(
                            self._record,
                            "Field '{}' items must contain at least {} words".format(
                                self._field.name,
                                item_min_length
                            )
                        )

            # Min/max char count of full item
            else:
                if item_max_length is not None:
                    if len(item) > item_max_length:
                        raise ValidationError(
                            self._record,
                            "Field '{}' items cannot contain more than {} characters".format(
                                self._field.name,
                                item_max_length
                            )
                        )
                if item_min_length is not None:
                    if len(item) < item_min_length:
                        raise ValidationError(
                            self._record,
                            "Field '{}' items must contain at least {} characters".format(
                                self._field.name,
                                item_min_length
                            )
                        )
1051692
function validate (o) {
  if (-1 === o.db.w || 0 === o.db.w) {
    if (o.db.journal || o.db.fsync || o.db.safe) {
      throw new Error(
          'Invalid writeConcern: '
        + 'w set to -1 or 0 cannot be combined with safe|fsync|journal');
    }
  }
}
885856
def validate(self):
        
        # Ange Albertini (@angie4771) can kill me for this! :)
        if self.dosHeader.e_magic.value != consts.MZ_SIGNATURE:
            raise excep.PEException("Invalid MZ signature. Found %d instead of %d." % (self.dosHeader.magic.value, consts.MZ_SIGNATURE))
        
        if self.dosHeader.e_lfanew.value > len(self):
            raise excep.PEException("Invalid e_lfanew value. Probably not a PE file.")
            
        if self.ntHeaders.signature.value != consts.PE_SIGNATURE: 
            raise excep.PEException("Invalid PE signature. Found %d instead of %d." % (self.ntHeaders.optionaHeader.signature.value, consts.PE_SIGNATURE))
            
        if self.ntHeaders.optionalHeader.numberOfRvaAndSizes.value > 0x10:
            print excep.PEWarning("Suspicious value for NumberOfRvaAndSizes: %d." % self.ntHeaders.optionaHeader.numberOfRvaAndSizes.value)
675075
async def validate(state, holdout_glob):
  

  if not glob.glob(holdout_glob):
    print('Glob "{}" didn\'t match any files, skipping validation'.format(
          holdout_glob))
  else:
    await run(
        'python3', 'validate.py', holdout_glob,
        '--flagfile={}'.format(os.path.join(FLAGS.flags_dir, 'validate.flags')),
        '--work_dir={}'.format(fsdb.working_dir()))
617452
def validate(self):
        """"""
        if self.error:
            return False

        for v in self.validators:
            self.error = v(self.value)
            if self.error:
                return False

        return True
848142
def validate_input(self):
        """"""
        if self.vert[1] <= self.vert[0]:
            raise ValueError(u'{} must be larger than {}'.format(self.vert[1], self.vert[0]))