validate "miner" arguments
328091
function validate (uri, collection, cb) {
  if ('function' != typeof cb) {
    throw new TypeError('cb must be a function');
  }

  if ('string' != typeof collection) {
    throw new TypeError('collection must be a string');
  }

  if ('string' != typeof uri) {
    throw new TypeError('uri must be a string');
  }
}
1084324
def Validate(self):
    """"""
    self.pathspec.Validate()

    if (self.HasField("start_time") and self.HasField("end_time") and
        self.start_time > self.end_time):
      raise ValueError("Start time must be before end time.")

    if not self.path_regex and not self.data_regex and not self.path_glob:
      raise ValueError("A Find specification can not contain both an empty "
                       "path regex and an empty data regex")
511107
def _validate_entries(self, processes):
        
        errors = list()

        # First we'll make sure there's no mismatch between the filesystem
        # and the list of files in the manifest(s)
        only_in_manifests, only_on_fs = self.compare_manifests_with_fs()
        for path in only_in_manifests:
            e = FileMissing(path)
            logger.warning(str(e))
            errors.append(e)
        for path in only_on_fs:
            e = UnexpectedFile(path)
            logger.warning(str(e))
            errors.append(e)

        # To avoid the overhead of reading the file more than once or loading
        # potentially massive files into memory we'll create a dictionary of
        # hash objects so we can open a file, read a block and pass it to
        # multiple hash objects

        available_hashers = set()
        for alg in self.algs:
            try:
                hashlib.new(alg)
                available_hashers.add(alg)
            except ValueError:
                logger.warning("Unable to validate file contents using unknown %s hash algorithm", alg)

        if not available_hashers:
            raise RuntimeError("%s: Unable to validate bag contents: none of the hash algorithms in %s are supported!" % (self, self.algs))

        def _init_worker():
            signal.signal(signal.SIGINT, signal.SIG_IGN)

        args = ((self.path, rel_path, hashes, available_hashers) for rel_path, hashes in list(self.entries.items()))

        try:
            if processes == 1:
                hash_results = list(map(_calc_hashes, args))
            else:
                try:
                    pool = multiprocessing.Pool(processes if processes else None, _init_worker)
                    hash_results = pool.map(_calc_hashes, args)
                finally:
                    try:
                        pool.terminate()
                    except:
                        # we really don't care about any exception in terminate()
                        pass
        # Any unhandled exceptions are probably fatal
        except:
            logger.exception("unable to calculate file hashes for %s", self)
            raise

        for rel_path, f_hashes, hashes in hash_results:
            for alg, computed_hash in list(f_hashes.items()):
                stored_hash = hashes[alg]
                if stored_hash.lower() != computed_hash:
                    e = ChecksumMismatch(rel_path, alg, stored_hash.lower(), computed_hash)
                    logger.warning(str(e))
                    errors.append(e)

        if errors:
            raise BagValidationError("invalid bag", errors)
1346384
function validate () {
  var env = state.env('NODE_ENV');
  var uri = state.env('MONGO_URI');
  var notTestEnv = env !== 'test';
  if (notTestEnv) {
    throw new Error('NODE_ENV must be set to "test".');
  }
  var notTestDb = word.test(uri) === false;
  if (notTestDb) {
    throw new Error('MONGO_URI must contain "test" word.');
  }
}
736389
def validate_proxy_args(cls, *args):
        """"""
        supplied_proxies = Counter((not arg for arg in (*args,))).get(False)
        if not supplied_proxies:
            return
        elif supplied_proxies > 1:
            raise RaccoonException("Must specify only one of the following:\n"
                                   "--tor-routing, --proxy-list, --proxy")
1365414
def mine_block(self, *args: Any, **kwargs: Any) -> BaseBlock:
        
        packed_block = self.pack_block(self.block, *args, **kwargs)

        final_block = self.finalize_block(packed_block)

        # Perform validation
        self.validate_block(final_block)

        return final_block
523906
def _mine_flush(self, load, skip_verify=False):
        '''
        
        '''
        if not skip_verify and 'id' not in load:
            return False
        if self.opts.get('minion_data_cache', False) or self.opts.get('enforce_mine_cache', False):
            return self.cache.flush('minions/{0}'.format(load['id']), 'mine')
        return True
388780
def mine_block(self, *args: Any, **kwargs: Any) -> BaseBlock:
        
        mined_block = self.get_vm(self.header).mine_block(*args, **kwargs)

        self.validate_block(mined_block)

        self.chaindb.persist_block(mined_block)
        self.header = self.create_header_from_parent(mined_block.header)
        return mined_block
781542
function validate(cmd, args, info) {
  AbstractCommand.prototype.validate.apply(this, arguments);
  var offset = parseInt('' + args[1]);
  if(isNaN(offset) || offset < 0 || offset > Constants.MAX_BIT_LEN) {
    throw IntegerRange;
  }
  args[1] = offset;
}
1000071
def _validate(self, p):
        
        if self._is_operator(p):
            for operator_or_filter in (p[1] if p[0] != '!' else [p[1]]):
                if p[0] == '^':
                    self._validate_xor_args(p)
                self._validate(operator_or_filter)
        elif not self._is_value_filter(p) and not self._is_key_filter(p):
            raise ValueError('Not a valid operator or filter - {0}'.format(p))
1158636
def _validate_param(param):  # pylint: disable=too-many-branches
    

    detail = None

    if param.oper not in goldman.config.QUERY_FILTERS:
        detail = 'The query filter {} is not a supported ' \
                 'operator. Please change {} & retry your ' \
                 'request'.format(param.oper, param)

    elif param.oper in goldman.config.GEO_FILTERS:
        try:
            if not isinstance(param.val, list) or len(param.val) <= 2:
                raise ValueError
            else:
                param.val = [float(i) for i in param.val]
        except ValueError:
            detail = 'The query filter {} requires a list ' \
                     'of floats for geo evaluation. Please ' \
                     'modify your request & retry'.format(param)

    elif param.oper in goldman.config.ENUM_FILTERS:
        if not isinstance(param.val, list):
            param.val = [param.val]

        param.val = tuple(param.val)

    elif isinstance(param.val, list):
        detail = 'The query filter {} should not be specified more ' \
                 'than once or have multiple values. Please modify ' \
                 'your request & retry'.format(param)

    elif param.oper in goldman.config.BOOL_FILTERS:
        try:
            param.val = str_to_bool(param.val)
        except ValueError:
            detail = 'The query filter {} requires a boolean ' \
                     'for evaluation. Please modify your ' \
                     'request & retry'.format(param)

    elif param.oper in goldman.config.DATE_FILTERS:
        try:
            param.val = str_to_dt(param.val)
        except ValueError:
            detail = 'The query filter {} supports only an ' \
                     'epoch or ISO 8601 timestamp. Please ' \
                     'modify your request & retry'.format(param)

    elif param.oper in goldman.config.NUM_FILTERS:
        try:
            param.val = int(param.val)
        except ValueError:
            detail = 'The query filter {} requires a number ' \
                     'for evaluation. Please modify your ' \
                     'request & retry'.format(param)

    if detail:
        raise InvalidQueryParams(**{
            'detail': detail,
            'links': LINK,
            'parameter': PARAM,
        })
766473
def check_merkle_hash(self):
        """"""
        calculated_hash = merkle([tx.hash() for tx in self.txs], double_sha256)
        if calculated_hash != self.merkle_root:
            raise BadMerkleRootError(
                "calculated %s but block contains %s" % (b2h(calculated_hash), b2h(self.merkle_root)))
842293
def validate_pwhash(_self, params):
    
    pwhash, nonce, aead, key_handle = get_pwhash_bits(params)
    d_aead = aead.decode('hex')
    plaintext_len = len(d_aead) - pyhsm.defines.YSM_AEAD_MAC_SIZE
    pw = pwhash.ljust(plaintext_len, chr(0x0))
    if hsm.validate_aead(nonce.decode('hex'), key_handle, d_aead, pw):
        return "OK pwhash validated"
    return "ERR Could not validate pwhash"
110579
def validate
      raise ArgumentError.new('No vuln_id.') unless @vuln_id
      raise ArgumentError.new('No scope.') unless @scope
      raise ArgumentError.new('No reason.') unless @reason

      case @scope
      when Scope::ALL_INSTANCES
        @asset_id = @port = @vuln_key = nil
      when Scope::ALL_INSTANCES_ON_A_SPECIFIC_ASSET
        raise ArgumentError.new('No asset_id.') unless @asset_id
        @port = @vuln_key = nil
      when Scope::SPECIFIC_INSTANCE_OF_SPECIFIC_ASSET
        raise ArgumentError.new('No asset_id.') unless @asset_id
        raise ArgumentError.new('Port or vuln_key is required.') unless @port || @vuln_key
      when Scope::ALL_INSTANCES_IN_A_SPECIFIC_SITE
        raise ArgumentError.new('No site_id.') unless @site_id
      else
        raise ArgumentError.new("Invalid scope: #{@scope}")
      end
    end
585056
def validate_arguments(self, locals_dict):
        '''
        
        '''

        for key, value, validator in self.__map_arguments(locals_dict):
            if not self.__is_valid(value, validator):
                key_name = repr(key)
                func_name = self.__function.__name__
                annotation = self.__argument_annotation.get(key)
                message = self.ARG_TYPE_ERROR_MESSAGE.format(
                    key_name,
                    func_name,
                    self.__format_expectation(annotation),
                    value.__class__.__name__)
                raise TypesafetyError(message)
1142101
def validate_args(args):
    """"""
    if not any([args.environment, args.stage, args.account]):
        sys.exit(NO_ACCT_OR_ENV_ERROR)
    if args.environment and args.account:
        sys.exit(ENV_AND_ACCT_ERROR)
    if args.environment and args.role:
        sys.exit(ENV_AND_ROLE_ERROR)
118543
def validate(model:nn.Module, dl:DataLoader, loss_func:OptLossFunc=None, cb_handler:Optional[CallbackHandler]=None,
             pbar:Optional[PBar]=None, average=True, n_batch:Optional[int]=None)->Iterator[Tuple[Union[Tensor,int],...]]:
    ""
    model.eval()
    with torch.no_grad():
        val_losses,nums = [],[]
        if cb_handler: cb_handler.set_dl(dl)
        for xb,yb in progress_bar(dl, parent=pbar, leave=(pbar is not None)):
            if cb_handler: xb, yb = cb_handler.on_batch_begin(xb, yb, train=False)
            val_loss = loss_batch(model, xb, yb, loss_func, cb_handler=cb_handler)
            val_losses.append(val_loss)
            if not is_listy(yb): yb = [yb]
            nums.append(yb[0].shape[0])
            if cb_handler and cb_handler.on_batch_end(val_losses[-1]): break
            if n_batch and (len(nums)>=n_batch): break
        nums = np.array(nums, dtype=np.float32)
        if average: return (to_np(torch.stack(val_losses)) * nums).sum() / nums.sum()
        else:       return val_losses