/*
validate the contents of the basket (such as allowable stock)
@param string $sMessageManager - the manager to which error messages should be sent
@return boolean
170405
public function ValidateBasketContents($sMessageManager)
    {
        $bIsValid = true;
        $oMessage = TCMSMessageManager::GetInstance();
        $iPt = $this->getItemPointer();
        $this->GoToStart();
        while ($oTmp = $this->Next()) {
            if ($oTmp->TotalStockAvailable() < $oTmp->dAmount) {
                $aErrorCodes = $oTmp->GetSQLWithTablePrefix();
                $aErrorCodes['dStockWanted'] = $oTmp->dAmount;
                if ($oTmp->TotalStockAvailable() > 0) {
                    $aErrorCodes['dStockAvailable'] = $oTmp->TotalStockAvailable();
                    $oMessage->AddMessage($sMessageManager, 'ERROR-ADD-TO-BASKET-NOT-ENOUGH-STOCK', $aErrorCodes);
                    $this->validateBasketContentBuyable($oTmp, $sMessageManager);
                } else {
                    $oMessage->AddMessage($sMessageManager, 'ERROR-ADD-TO-BASKET-NO-STOCK', $aErrorCodes);
                }
                $oTmp->dAmount = $oTmp->TotalStockAvailable();
                $this->UpdateItemAmount($oTmp);
                $bIsValid = false;
            } else {
                $bIsValid = $this->validateBasketContentBuyable($oTmp, $sMessageManager) && $bIsValid;
            }
        }
        if ($iPt > $this->Length()) {
            $iPt = $this->Length();
        }
        $this->setItemPointer($iPt);

        return $bIsValid;
    }
1094313
public function validate(Message $message)
    {
        if ($message->getTitleLength() > self::CHARACTER_LIMIT) {
            $message->addStatus(new LimitTheTitleLengthTo69CharactersStatus());
        }
    }
387687
protected function CheckAuthorisationResponse($sMessageConsumer = '')
    {
        $bResponseSuccessful = false;
        if (empty($sMessageConsumer)) {
            $sMessageConsumer = $this->GetMsgManagerName();
        }
        $sReturnMessage = $this->GetErrorCodesFromResponse();
        if (!empty($sReturnMessage)) {
            $oMsgManager = TCMSMessageManager::GetInstance();
            $oMsgManager->AddMessage($sMessageConsumer, $sReturnMessage);
        } else {
            $bResponseSuccessful = true;
        }

        return $bResponseSuccessful;
    }
502582
public function validate(AbstractValidator $validator, $removeRequired = false, array $messages = [], array $customAttributes = [])
    {
        return $validator->validate($removeRequired);
        /*try {
            return $validator->validate($removeRequired);
        } catch (ValidationException $e) {
            $this->throwValidationException($e->getErrors());
        }*/

//              $this->throwValidationException($request, $validator);
        // $validator = $this->getValidationFactory()->make($request->all(), $rules, $messages, $customAttributes);

    }
1095468
public function validate(Message $message)
    {
        if (self::isLambdaStyle($message)) {
            $message = self::convertLambdaMessage($message);
        }

        // Get the certificate.
        $this->validateUrl($message['SigningCertURL']);
        $certificate = call_user_func($this->certClient, $message['SigningCertURL']);
        if ($certificate === false) {
            throw new InvalidSnsMessageException(
                "Cannot get the certificate from \"{$message['SigningCertURL']}\"."
            );
        }

        // Extract the public key.
        $key = openssl_get_publickey($certificate);
        if (!$key) {
            throw new InvalidSnsMessageException(
                'Cannot get the public key from the certificate.'
            );
        }

        // Verify the signature of the message.
        $content = $this->getStringToSign($message);
        $signature = base64_decode($message['Signature']);
        if (openssl_verify($content, $signature, $key, OPENSSL_ALGO_SHA1) != 1) {
            throw new InvalidSnsMessageException(
                'The message signature is invalid.'
            );
        }
    }
156460
public function methodNotAllowed($msg = '', $errorCode = null, $headers = [])
    {
        return $this->getErrorResponse($msg, $errorCode, self::HTTP_METHOD_NOT_ALLOWED, $headers);
    }
246245
private function isValidCommitMessage($regularExpression, $commitMessage)
    {
        return $this->mergeValidator->isMerge() || preg_match(sprintf('/%s/', $regularExpression), $commitMessage);
    }
174245
public function RemoveInvalidVouchers($sMessangerName, $oBasket = null)
    {
        // since the min value of the basket for which a voucher may work is affected by other vouchers,
        // we need to remove the vouchers first, and then add them one by one back to the basket
        // we suppress the add messages, but keep the negative messages

        if (is_null($oBasket)) {
            $oBasket = TShopBasket::GetInstance();
        }
        $oMessageManager = TCMSMessageManager::GetInstance();

        // get copy of vouchers
        $aVoucherList = $this->_items;
        $this->Destroy();
        $bInvalidVouchersFound = false;
        foreach ($aVoucherList as $iVoucherKey => $oVoucher) {
            /** @var $oVoucher TdbShopVoucher */
            $cVoucherAllowUseCode = $oVoucher->AllowUseOfVoucher();
            if (TdbShopVoucher::ALLOW_USE == $cVoucherAllowUseCode) {
                $this->AddItem($oVoucher);
            } else {
                $bInvalidVouchersFound = true;
                $this->RemoveInvalidVoucherHook($oVoucher, $oBasket);
                // send message that the voucher was removed
                $aMessageData = $oVoucher->GetObjectPropertiesAsArray();
                $aMessageData['iRemoveReasoneCode'] = $cVoucherAllowUseCode;
                $oMessageManager->AddMessage($sMessangerName, 'VOUCHER-ERROR-NO-LONGER-VALID-FOR-BASKET', $aMessageData);
            }
        }

        if ($bInvalidVouchersFound) {
            // recalculate the basket
            $oBasket->RecalculateBasket();
        }
    }
613798
public function setValidationError(CoverFishResult $coverFishResult, $errorCode, $errorMessage = null)
    {
        // skip validation if incoming mapping result is already invalid!
        if (false === $coverFishResult->isPass()) {
            return $coverFishResult;
        }

        $coverFishResult->setPass(false);
        $coverFishResult->addError(new CoverFishMessageError($errorCode, $errorMessage));

        return $coverFishResult;
    }
12552
public function notImplemented($msg = '', $errorCode = null, $headers = [])
    {
        return $this->getErrorResponse($msg, $errorCode, self::HTTP_NOT_IMPLEMENTED, $headers);
    }
643825
protected function whenValidated($messageBag, $sendHeaders)
    {
        $messages = empty($messageBag) ? [] : $messageBag->getMessages();
        if ($this->request->ajax() && $sendHeaders) {
            $return = [];
            foreach ($messages as $key => $phrases) {
                if (str_contains($key, '[]')) {
                    $key = str_replace(['[', ']'], '_', $key);
                }
                $return[$key] = $phrases;
            }
            return $this->response($return);
        }
        if (!empty($messages)) {
            $this->messageBag = $messageBag;
            return false;
        }

        return true;
    }
937630
protected function isValidByLoadedValidators(
        PurchasableInterface $purchasable,
        $stockRequired,
        $useStock
    ) {
        foreach ($this->validators as $validator) {
            $stockUpdateNamespace = $validator->getPurchasableNamespace();
            if ($purchasable instanceof $stockUpdateNamespace) {
                return $validator->isStockAvailable(
                    $purchasable,
                    $stockRequired,
                    $useStock
                );
            }
        }

        return false;
    }
241663
protected function isValidMessage($message): Message
    {
        if ($message instanceof Message) {
            return $message;
        }

        if (\is_string($message) || $message instanceof Attachment) {
            return Message::create($message);
        }

        throw new MessengerException(sprintf(
            'message must be a string or an instance of %s or %s.',
            Message::class,
            Attachment::class
        ));
    }
1158198
public function ValidateUserInput()
    {
        $bIsValid = parent::ValidateUserInput();

        if ($bIsValid) {
            $oMsgManager = TCMSMessageManager::GetInstance();

            if (!array_key_exists('accountOwner', $this->aPaymentUserData) || empty($this->aPaymentUserData['accountOwner'])) {
                $oMsgManager->AddMessage(self::MSG_MANAGER_NAME.'-accountOwner', 'ERROR-USER-REQUIRED-FIELD-MISSING');
                $bIsValid = false;
            }

            if (!array_key_exists('accountNr', $this->aPaymentUserData) || empty($this->aPaymentUserData['accountNr'])) {
                $oMsgManager->AddMessage(self::MSG_MANAGER_NAME.'-accountNr', 'ERROR-USER-REQUIRED-FIELD-MISSING');
                $bIsValid = false;
            }

            if (!array_key_exists('bankNr', $this->aPaymentUserData) || empty($this->aPaymentUserData['bankNr'])) {
                $oMsgManager->AddMessage(self::MSG_MANAGER_NAME.'-bankNr', 'ERROR-USER-REQUIRED-FIELD-MISSING');
                $bIsValid = false;
            }
        }

        return $bIsValid;
    }
1018871
public function onEventInvalid($sMessage)
    {
        if(($this->xInvalidCallback))
        {
            call_user_func_array($this->xInvalidCallback, array($this->xResponse, $sMessage));
        }
        return $this->xResponse;
    }
1250157
private function processLeadingIndentationTags ($sMessage)
    {
        $bTagFound = true;
        while ($bTagFound && strlen($sMessage) > 0) {
            if (substr($sMessage, 0, $this->iIndentTagLength) == $this->aConfig['indent_tag']) {
                $this->iIndentationLevel++;
                $sMessage = substr($sMessage, $this->iIndentTagLength);
            } elseif (substr($sMessage, 0, $this->iUnindentTagLength) == $this->aConfig['unindent_tag']) {
                $this->iIndentationLevel = max(0, $this->iIndentationLevel-1);
                $sMessage = substr($sMessage, $this->iUnindentTagLength);
            } else {
                $bTagFound = false;
            }
        }
        return $sMessage;
    }
987546
public function getMessageValidator(): ValidateMessage
    {
        $messageValidator = new ValidateMessageImplementation(
            [
                new CapitalizeTheSubjectLineValidator(),
                new DoNotEndTheSubjectLineWithAPeriodValidator(),
                new LimitTheBodyWrapLengthTo72CharactersValidator(),
                new LimitTheTitleLengthTo69CharactersValidator(),
                new SeparateSubjectFromBodyWithABlankLineValidator(),
                new SoftLimitTheTitleLengthTo50CharactersValidator(),
            ]
        );

        return $messageValidator;
    }