Validate the given receipt.

@param string $receipt
@return bool
@throws RunTimeException
164540
public function validate($receipt)
    {
        // Load the receipt that needs to verified as an XML document.
        $dom = new \DOMDocument;
        if (@$dom->loadXML($receipt) === false) {
            throw new RunTimeException('Invalid XML');
        }

        // The certificateId attribute is present in the document root, retrieve it.
        $certificateId = $dom->documentElement->getAttribute('CertificateId');
        if (empty($certificateId)) {
            throw new RunTimeException('Missing CertificateId in receipt');
        }

        // Retrieve the certificate from the official site.
        $certificate = $this->retrieveCertificate($certificateId);

        return $this->validateXml($dom, $certificate);
    }
520561
private function validateResponse($response) {
        if ($response->getStatusCode() !== 200) {
            $statusCode = $response->getStatusCode();
            throw new ServerException('Server responded with HTTP status ' . $statusCode, $statusCode);
        } else if (strpos($response->getHeader('Content-Type')[0], 'application/json') === false) {
            throw new ServerException('Server did not respond with the expected content-type (application/json)');
        }

        try {
            $body = (string) $response->getBody();
            $json = json_decode($body, true);
            if (json_last_error()) {
                throw new ServerException(json_last_error_msg());
            }
        } catch (RuntimeException $e) {
            throw new ServerException($e->getMessage());
        }
    }
1116884
public function validate() {        
        if($this instanceof Cache\CacheableValidatableInterface && $this->isValidationCacheEnabled() && $this->lastValidationResult instanceof ValidationResultSet) {
            return $this->lastValidationResult;
        }
        
        $validationResultSet = $this->validateValue($this->getValue());
        
        if($this instanceof Cache\CacheableValidatableInterface && $this->isValidationCacheEnabled()) {
            $this->lastValidationResult = $validationResultSet;
        }
            
        return $validationResultSet;
    }
193611
public static function validate($entity)
    {
        if (Kernel::VERSION_ID >= 40000) {
            $classFound = class_exists($entity, true);

            if (!$classFound) {
                throw new \InvalidArgumentException(sprintf('Entity "%s" was not found', $entity));
            }

            return $entity;
        }

        if (!preg_match('{^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*:[a-zA-Z0-9_\x7f-\xff\\\/]+$}', $entity)) {
            throw new \InvalidArgumentException(sprintf('The entity name isn\'t valid ("%s" given, expecting something like AcmeBlogBundle:Blog/Post)', $entity));
        }

        return $entity;
    }
455518
public function validate($subject): bool
    {
        if (\is_int($this->schema['minProperties']) && $this->schema['minProperties'] >= 0) {
            if (\count($subject) < $this->schema['minProperties']) {
                return false;
            }
        }
        return true;
    }
259798
protected function validate()
    {
        /** @var Parameter[] $missingItems */
        $missingItems = \array_filter($this->_options + $this->_arguments, function ($item) {
            /* @var Parameter $item */
            return $item->required() && \in_array($this->_values[$item->attributeName()], [null, []]);
        });

        foreach ($missingItems as $item) {
            list($name, $label) = [$item->name(), 'Argument'];
            if ($item instanceof Option) {
                list($name, $label) = [$item->long(), 'Option'];
            }

            throw new RuntimeException(
                \sprintf('%s "%s" is required', $label, $name)
            );
        }
    }
473969
public function validateSign($secret)
	{

		$inputData = $this->input->all();
		Secure::sign($inputData, $this->sid(), $secret);
		if ($inputData['sign'] !== $this->input->sign) {
			throw new ProcessorException(ProcessorException::INVALID_SIGN);
		}

	}
197847
public function run_check() {
		$r = $this->run();

		if ( $r->return_code || !empty( $r->STDERR ) ) {
			throw new \RuntimeException( $r );
		}

		return $r;
	}
271660
public function send(Receipt $receipt, $check = false)
    {
        $this->initSoapClient();

        $response = $this->processData($receipt, $check);

        isset($response->Chyba) && $this->processError($response->Chyba);
        isset($response->Varovani) && $this->processWarnings($response->Varovani);

        $this->fik = $check ? null : $response->Potvrzeni->fik;
        return $this->fik;
    }
1223398
public function validate()
    {
        if ($this->_amount === null) {
            $this->setValidationError('Payment amount not specified');
            return false;
        }

        $value = $this->_amount->getValue();
        if (empty($value) || $value <= 0.0) {
            $this->setValidationError('Invalid payment amount value: '.$value);
            return false;
        }

        if ($this->_receipt !== null && $this->_receipt->notEmpty()) {
            $email = $this->_receipt->getEmail();
            $phone = $this->_receipt->getPhone();
            if (empty($email) && empty($phone)) {
                $this->setValidationError('Both email and phone values are empty in receipt');
                return false;
            }
        }

        return true;
    }
405027
public function validate($subject): bool
    {
        if (\is_array($this->schema['items'])) {
            $schemaFirstKey = \array_keys($this->schema['items'])[0];
            $schemaType = \is_int($schemaFirstKey) ? 'array' : 'object';

            if (($schemaType === 'object') && !$this->validateItemsSchemaObject($subject, $this->schema)) {
                return false;
            }
            if ($schemaType === 'array' && !$this->validateItemsSchemaArray($subject, $this->schema)) {
                return false;
            }
        }
        return true;
    }
143014
protected function validate($validator)
    {
        $validator->validatePresence('operation');

        // Validation for a new refund request
        if ($this->params['operation'] == 'request')
        {
            $validator->validatePresence('hash');
            $validator->validatePresence('amount');
            $validator->validatePresence('description');
        }
        // Validation a cancel refund request
        else
        {
            $validator->validatePresenceOr('merchant_refund_code', 'refund_id');
        }
    }
458073
public function validate($subject): bool
    {
        if (\is_bool($this->schema['uniqueItems']) && ($this->schema['uniqueItems'] === true)) {
            if (\count($subject) !== \count(\array_unique($subject))) {
                return false;
            }
        }
        return true;
    }
677450
private function validate()
    {
        if (!class_exists($this->class)) {
            throw new \RuntimeException(sprintf('Class %s does not exist, is this the correct namespace?', $this->class));
        }
        if (!in_array($this->method, get_class_methods($this->class))) {
            throw new \RuntimeException(sprintf('The method "%s" does not exist in "%s" class.', $this->method, $this->class));
        }
    }
110634
protected function _validate($args = null)
    {
        $this->_runtime = ($args === null) ? $this->params : $args;

        $errors = [];

        if (!isset($this->_runtime['type'])) {
            $this->_runtime['type'] = 'regular';
        }

        if (!isset($this->_runtime['debug'])) {
            $this->_runtime['debug'] = false;
        }

        // Validate Log path
        $this->_runtime['log'] = isset($this->_runtime['log'])
            ? $this->_runtime['log']
            : (Configure::read('CakeResque.Scheduler.log') && $this->_runtime['type'] === 'scheduler'
                ? Configure::read('CakeResque.Scheduler.log')
                : Configure::read('CakeResque.Worker.log')
            );
        if (substr($this->_runtime['log'], 0, 2) == './') {
            $this->_runtime['log'] = LOGS . substr($this->_runtime['log'], 2);
        } elseif (substr($this->_runtime['log'], 0, 1) != '/') {
            $this->_runtime['log'] = LOGS . $this->_runtime['log'];
        }

        // Validate Interval
        $this->_runtime['interval'] = isset($this->_runtime['interval'])
            ? $this->_runtime['interval']
            : (Configure::read('CakeResque.Scheduler.Worker.interval') && $this->_runtime['type'] === 'scheduler'
                ? Configure::read('CakeResque.Scheduler.Worker.interval')
                : Configure::read('CakeResque.Worker.interval')
            );
        if (!is_numeric($this->_runtime['interval'])) {
            $errors[] = __d('cake_resque', 'Interval time [{0}] is not valid. Please enter a valid number', $this->_runtime['interval']);
        } else {
            $this->_runtime['interval'] = (int)$this->_runtime['interval'];
        }

        // Validate workers number
        $this->_runtime['workers'] = isset($this->_runtime['workers']) ? $this->_runtime['workers'] : Configure::read('CakeResque.Worker.workers');
        if (!is_numeric($this->_runtime['workers'])) {
            $errors[] = __d('cake_resque', 'Workers number [{0}] is not valid. Please enter a valid number', $this->_runtime['workers']);
        } else {
            $this->_runtime['workers'] = (int)$this->_runtime['workers'];
        }

        $this->_runtime['queue'] = isset($this->_runtime['queue']) ? $this->_runtime['queue'] : Configure::read('CakeResque.Worker.queue');

        // Validate user
        if (isset($this->_runtime['user'])) {
            $this->_runtime['user'] = $this->_runtime['user'];
        } elseif (Configure::read('CakeResque.Worker.user')) {
            $this->_runtime['user'] = Configure::read('CakeResque.Worker.user');
        } else {
            $user = $this->__getProcessOwner();
            $this->_runtime['user'] = empty($user) ? get_current_user() : $user;
        }

        $this->_runtime['verbose'] = isset($this->params['verbose']) ? $this->params['verbose'] : Configure::read('CakeResque.Worker.verbose');

        $output = [];
        exec('id ' . $this->_runtime['user'] . ' 2>&1', $output, $status);
        if ($status != 0) {
            $errors[] = __d('cake_resque', 'User [{0}] does not exists. Please enter a valid system user', $this->_runtime['user']);
        }

        $this->_runtime['Log']['handler'] = isset($this->_runtime['log-handler'])
            ? $this->_runtime['log-handler']
            : (Configure::read('CakeResque.Scheduler.Log.handler') && $this->_runtime['type'] === 'scheduler'
                ? Configure::read('CakeResque.Scheduler.Log.handler')
                : Configure::read('CakeResque.Log.handler')
            );

        $this->_runtime['Log']['target'] = isset($this->_runtime['log-handler-target'])
            ? $this->_runtime['log-handler-target']
            : (Configure::read('CakeResque.Scheduler.Log.target') && $this->_runtime['type'] === 'scheduler'
                ? Configure::read('CakeResque.Scheduler.Log.target')
                : Configure::read('CakeResque.Log.target')
            );
        if (substr($this->_runtime['Log']['target'], 0, 2) == './') {
            $this->_runtime['Log']['target'] = TMP . 'logs' . DS . substr($this->_runtime['Log']['target'], 2);
        }

        if (!empty($errors)) {
            foreach ($errors as $error) {
                $this->err('<error>' . __d('cake_resque', 'Error') . ':</error> ' . $error);
            }
            $this->out();
        }

        return empty($errors);
    }
508404
protected function validateEmailVerification(array $credentials)
    {
        if (is_null($user = $this->getUser($credentials))) {
            return static::INVALID_USER;
        }

        if (! $this->validateToken($user, $credentials)) {
            return static::INVALID_TOKEN;
        }

        if (! $this->validateTimestamp($credentials['expiration'])) {
            return static::EXPIRED_TOKEN;
        }

        return $user;
    }
1073570
public function validateSource($source)
    {
        if ($source instanceof User) {
            $validator = new UserValidator();
            $response = $validator->validate($source);
        } elseif ($source instanceof UserGroup) {
            $validator = new UserGroupValidator();
            $response = $validator->validate($source);
        } else {
            $this->addError('source', 'Source must be a valid instance of User or UserGroup');
            return false;
        }

        if (!$response) {
            $this->addError('source', 'Source must be a valid instance of User or UserGroup class - ' . $validator->getErrorsAsString());
        }

        return $response;
    }