Validate the validator election vote transaction. Since `VOTE` extends `TRANSFER`
           transaction, all the validations for `CREATE` transaction should be inherited
960491
def validate_schema(cls, tx):
        
        _validate_schema(TX_SCHEMA_COMMON, tx)
        _validate_schema(TX_SCHEMA_TRANSFER, tx)
        _validate_schema(cls.TX_SCHEMA_CUSTOM, tx)
408992
protected function _validateTransaction(Transaction $transaction)
    {
        if (!$transaction->getParent() && in_array($transaction->getType()->getValue(), array(
            Transaction\TransactionType::CAPTURE,
            Transaction\TransactionType::REFUND
        ))) {
            throw ValidationException::parentTransactionRequired();
        }
    }
1056171
def validate_card_transfer_p2th(deck: Deck, vout: dict) -> None:
    ''''''

    error = {"error": "Card transfer is not properly tagged."}

    try:
        address = vout["scriptPubKey"].get("addresses")[0]
        if not address == deck.p2th_address:
            raise InvalidCardTransferP2TH(error)
    except TypeError as e:
        raise e
816248
def validate(context = Attributor::DEFAULT_ROOT_CONTEXT)
      raise AttributorException, 'validation conflict' if @validating
      @validating = true

      context = [context] if context.is_a? ::String
      keys_with_values = []
      errors = []

      self.class.attributes.each do |sub_attribute_name, sub_attribute|
        sub_context = self.class.generate_subcontext(context, sub_attribute_name)

        value = __send__(sub_attribute_name)
        keys_with_values << sub_attribute_name unless value.nil?

        if value.respond_to?(:validating) # really, it's a thing with sub-attributes
          next if value.validating
        end

        errors.concat sub_attribute.validate(value, sub_context)
      end
      self.class.requirements.each do |req|
        validation_errors = req.validate(keys_with_values, context)
        errors.concat(validation_errors) unless validation_errors.empty?
      end

      errors
    ensure
      @validating = false
    end
477264
def partial_verify_asset_transaction(asset_transaction)
      raise ArgumentError, "Asset Transaction is missing" if !asset_transaction

      # 1. Verify issuing transactions and collect transfer outputs
      cache_transactions do
        if !verify_issues(asset_transaction)
          return nil
        end

        # No transfer outputs, this transaction is verified.
        # If there are assets on some inputs, they are destroyed.
        if asset_transaction.transfer_outputs.size == 0
          # We keep inputs unverified to indicate that they were not even processed.
          return []
        end

        # 2. Fetch parent transactions to verify.
        # * Verify inputs from non-OpenAsset transactions.
        # * Return OA transactions for verification.
        # * Link each input to its OA transaction output.
        prev_unverified_atxs_by_hash = {}
        asset_transaction.inputs.each do |ain|
          txin = ain.transaction_input
          # Ask source if it has a cached verified transaction for this input.
          prev_atx = @source.verified_asset_transaction_for_hash(txin.previous_hash)
          if prev_atx
            BTC::Invariant(prev_atx.verified?, "Cached verified tx must be fully verified")
          end
          prev_atx ||= prev_unverified_atxs_by_hash[txin.previous_hash]
          if !prev_atx
            prev_tx = transaction_for_input(txin)
            if !prev_tx
              Diagnostics.current.add_message("Failed to load previous transaction for input #{ain.index}: #{txin.previous_id}")
              return nil
            end
            begin
              prev_atx = AssetTransaction.new(transaction: prev_tx)
              prev_unverified_atxs_by_hash[prev_atx.transaction_hash] = prev_atx
            rescue FormatError => e
              # Previous transaction is not a valid Open Assets transaction,
              # so we mark the input as uncolored and verified as such.
              ain.asset_id = nil
              ain.value = nil
              ain.verified = true
            end
          end
          # Remember a reference to this transaction so we can validate the whole `asset_transaction` when all previous ones are set and verified.
          ain.previous_asset_transaction = prev_atx
        end # each input

        # Return all unverified transactions.
        # Note: this won't include the already verified one.
        prev_unverified_atxs_by_hash.values
      end
    end
1339828
def _validate(self, schema):
        
        if isinstance(schema, _str_type):
            schema = self.validator.schema_registry.get(schema, schema)

        if schema is None:
            raise SchemaError(errors.SCHEMA_ERROR_MISSING)

        schema = copy(schema)
        for field in schema:
            if isinstance(schema[field], _str_type):
                schema[field] = rules_set_registry.get(schema[field],
                                                       schema[field])

        if not self.schema_validator(schema, normalize=False):
            raise SchemaError(self.schema_validator.errors)
816004
def validateCommit(self, commit: Commit, sender: str) -> bool:
        
        key = (commit.viewNo, commit.ppSeqNo)
        if not self.has_prepared(key):
            self.enqueue_commit(commit, sender)
            return False

        if self.commits.hasCommitFrom(commit, sender):
            raise SuspiciousNode(sender, Suspicions.DUPLICATE_CM_SENT, commit)

        # BLS multi-sig:
        pre_prepare = self.getPrePrepare(commit.viewNo, commit.ppSeqNo)
        why_not = self._bls_bft_replica.validate_commit(commit, sender, pre_prepare)

        if why_not == BlsBftReplica.CM_BLS_SIG_WRONG:
            self.logger.warning("{} discard Commit message from "
                                "{}:{}".format(self, sender, commit))
            raise SuspiciousNode(sender,
                                 Suspicions.CM_BLS_SIG_WRONG,
                                 commit)
        elif why_not is not None:
            self.logger.warning("Unknown error code returned for bls commit "
                                "validation {}".format(why_not))

        return True
474300
def validate(self,
                 asset,
                 amount,
                 portfolio,
                 algo_datetime,
                 algo_current_data):
        
        if self.restrictions.is_restricted(asset, algo_datetime):
            self.handle_violation(asset, amount, algo_datetime)
478329
def from_dict(cls, tx, skip_schema_validation=True):
        
        operation = tx.get('operation', Transaction.CREATE) if isinstance(tx, dict) else Transaction.CREATE
        cls = Transaction.resolve_class(operation)

        if not skip_schema_validation:
            cls.validate_id(tx)
            cls.validate_schema(tx)

        inputs = [Input.from_dict(input_) for input_ in tx['inputs']]
        outputs = [Output.from_dict(output) for output in tx['outputs']]
        return cls(tx['operation'], tx['asset'], inputs, outputs,
                   tx['metadata'], tx['version'], hash_id=tx['id'], tx_dict=tx)
355624
def elect(self, candidate_aggregates, candidate_id):
        

        # somewhat paranoid cross-check, but we've had this bug before..
        assert(candidate_id not in self.candidates_elected)

        elected_no = len(self.candidates_elected) + 1
        self.candidates_elected[candidate_id] = True

        transfer_value = 0
        excess_votes = paper_count = None
        if len(self.candidates_elected) != self.vacancies:
            excess_votes = max(candidate_aggregates.get_vote_count(candidate_id) - self.quota, 0)
            assert(excess_votes >= 0)
            paper_count = self.candidate_bundle_transactions.get_paper_count(candidate_id)
            if paper_count > 0:
                transfer_value = fractions.Fraction(excess_votes, paper_count)
            assert(transfer_value >= 0)
            self.election_distributions_pending.append((candidate_id, transfer_value, excess_votes))
        self.results.candidate_elected(
            CandidateElected(
                candidate_id=candidate_id,
                order=elected_no,
                excess_votes=excess_votes,
                paper_count=paper_count,
                transfer_value=transfer_value))
1335981
def run_validation(field_name, options)
      promise = Promise.new.resolve(nil)
      options.each_pair do |validation, args|
        # Call the specific validator, then merge the results back
        # into one large errors hash.
        klass = validation_class(validation, args)

        if klass
          # Chain on the promises
          promise = promise.then do
            klass.validate(self, field_name, args)
          end.then do |errs|
            errors.merge!(errs)
          end
        else
          fail "validation type #{validation} is not specified."
        end
      end

      promise
    end
653169
def validate(schema, data, owner=None):
    
    schema._validate(data=data, owner=owner)
973412
def validate(self,
                 asset,
                 amount,
                 portfolio,
                 algo_datetime,
                 algo_current_data):
        
        algo_date = algo_datetime.date()

        # Reset order count if it's a new day.
        if self.current_date and self.current_date != algo_date:
            self.orders_placed = 0
        self.current_date = algo_date

        if self.orders_placed >= self.max_count:
            self.handle_violation(asset, amount, algo_datetime)
        self.orders_placed += 1
558202
protected function setupValidations()
    {
        $this->validations->of(
            TransactionType::CAPTURE |
            TransactionType::EDIT |
            TransactionType::HOLD |
            TransactionType::RELEASE
        )
            ->check('transactionId')->isNotNull();

        $this->validations->of(TransactionType::EDIT)
            ->with(TransactionModifier::LEVEL_II)
            ->check('taxType')->isNotNull();

        $this->validations->of(TransactionType::REFUND)
            ->when('amount')->isNotNull()
            ->check('currency')->isNotNull();

        $this->validations->of(TransactionType::VERIFY_SIGNATURE)
            ->check('payerAuthenticationResponse')->isNotNull()
            ->check('amount')->isNotNull()
            ->check('currency')->isNotNull()
            ->check('orderId')->isNotNull();
    }
736945
def approvecommittee(self, committees, account=None, **kwargs):
        
        if not account:
            if "default_account" in self.config:
                account = self.config["default_account"]
        if not account:
            raise ValueError("You need to provide an account")
        account = Account(account, blockchain_instance=self)
        options = account["options"]

        if not isinstance(committees, (list, set, tuple)):
            committees = {committees}

        for committee in committees:
            committee = Committee(committee, blockchain_instance=self)
            options["votes"].append(committee["vote_id"])

        options["votes"] = list(set(options["votes"]))
        options["num_committee"] = len(
            list(filter(lambda x: float(x.split(":")[0]) == 0, options["votes"]))
        )

        op = operations.Account_update(
            **{
                "fee": {"amount": 0, "asset_id": "1.3.0"},
                "account": account["id"],
                "new_options": options,
                "extensions": {},
                "prefix": self.prefix,
            }
        )
        return self.finalizeOp(op, account["name"], "active", **kwargs)
206439
def validate(self, value, model_instance):
        
        if not isinstance(value, base.StateWrapper):
            raise exceptions.ValidationError(self.error_messages['wrong_type'] % value)
        elif not value.workflow == self.workflow:
            raise exceptions.ValidationError(self.error_messages['wrong_workflow'] % value.workflow)
        elif value.state not in self.workflow.states:
            raise exceptions.ValidationError(self.error_messages['invalid_state'] % value.state)
295385
def is_valid(self) -> bool:
        ''''''

        if not (self.blocknum >= self.vote.start_block and
                self.blocknum <= self.vote.end_block):
            return False

        if not self.confirmations >= 6:
            return False

        return True