Validates token from input
@return array
778144
public function token() {

		$session = new Session();

		$name  = $this -> getValue('_token-name');
		$value = $this -> getValue('_token-value');

		if((null !== $name && null !== $value && $session -> pull(['_token', $name]) !== $value) || null === $name || null === $value) {
			
			$instance = $this -> getMessageInstance();
			$instance :: setFieldnames(['_token']);
			$instance :: setError(null, '_token', 'Token mismatch');
			$this -> setPasses(false);
		}
	}
275484
public function validate() {

		// check whether a CSRF token was tainted
		
		if($this->enableCsrfToken && !$this->checkCsrfToken()) {

			throw new HtmlFormException('CSRF token mismatch.', HtmlFormException::CSRF_TOKEN_MISMATCH);

		}

		$this->formErrors = [];

		foreach($this->elements as $name => $e) {
			
			if(is_array($e)) {
				foreach($e as $ndx => $elem) {
				    if(!$elem->isValid()) {
                        if (!isset($this->formErrors[$name])) {
                            $this->formErrors[$name] = [];
                        }
                        $this->formErrors[$name][$ndx] = new FormError($elem->getValidationErrorMessage());
                    }
				}
			}

			else if(!$e->isValid()) {
				$this->formErrors[$name] = new FormError($e->getValidationErrorMessage());
			}
		}

		return $this;

	}
550109
protected function validateEmailAsPdfFields()
    {
        // Check for valid email address if no token syntax is used.
        $regexpEmail = '/^[^@<>,; "\']+@([^.@ ,;]+\.)+[^.@ ,;]+$/';
        if (!empty($this->submittedValues['emailTo']) && strpos($this->submittedValues['emailTo'], '[') === false && !preg_match($regexpEmail, $this->submittedValues['emailTo'])) {
            $this->errorMessages['emailTo'] = $this->t('message_validate_email_5');
        }

        // Check for valid email addresses if no token syntax is used.
        $regexpMultiEmail = '/^[^@<>,; "\']+@([^.@ ,;]+\.)+[^.@ ,;]+([,;][^@<>,; "\']+@([^.@ ,;]+\.)+[^.@ ,;]+)*$/';
        if (!empty($this->submittedValues['emailBcc']) && strpos($this->submittedValues['emailBcc'], '[') === false && !preg_match($regexpMultiEmail, $this->submittedValues['emailBcc'])) {
            $this->errorMessages['emailBcc'] = $this->t('message_validate_email_3');
        }

        // Check for valid email address if no token syntax is used.
        if (!empty($this->submittedValues['emailFrom']) && strpos($this->submittedValues['emailFrom'], '[') === false && !preg_match($regexpEmail, $this->submittedValues['emailFrom'])) {
            $this->errorMessages['emailFrom'] = $this->t('message_validate_email_4');
        }
    }
255755
protected function _validateInput()
    {
        $result = true;

        $oxid = $this->getEditObjectId();
        $parameters = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("editval");

        // if creating new language, checking if language already exists with
        // entered language abbreviation
        if (($oxid == -1) && $this->_checkLangExists($parameters['abbr'])) {
            $this->addDisplayException('LANGUAGE_ALREADYEXISTS_ERROR');
            $result = false;
        }

        // As the abbreviation is used in database view creation, check for allowed characters
        if (!$this->checkAbbreviationAllowedCharacters($parameters['abbr'])) {
            $this->addDisplayException('LANGUAGE_ABBREVIATION_INVALID_ERROR');
            $result = false;
        }

        // checking if language name is not empty
        if (empty($parameters['desc'])) {
            $this->addDisplayException('LANGUAGE_EMPTYLANGUAGENAME_ERROR');
            $result = false;
        }

        return $result;
    }
1226080
public function tokenize()
    {
        $this->inputStream->reset();

        $tokens = [];

        while ($token = $this->readToken()) {
            $tokens[] = $token;
        }

        return $tokens;
    }
375242
public function matched($input)
    {
        if ($this->token instanceof Token) {
            return $this->token->matched($input);
        }
        
        return $input;
    }
335134
final public function validate(): bool
    {
        // validate csrf token if required
        if ($this->_tokenRequired && !$this->_tokenOk) {
            App::$Session->getFlashBag()->add('warning', __('Hack attention: security token is wrong!'));
            return false;
        }
        // get all rules as array from method rules()
        $rules = $this->rules();
        // get default values of attributes
        $defaultAttr = $this->getAllProperties();

        // start validation: on this step class attribute values will be changed to input data if it valid
        $success = $this->runValidate($rules);

        // get not-passed validation fields as array
        $badAttributes = $this->getBadAttributes();
        // prevent warnings
        if (Any::isArray($badAttributes) && count($badAttributes) > 0) {
            foreach ($badAttributes as $attr) {
                if (Str::contains('.', $attr)) { // sounds like dot-separated array attr
                    $attrName = strstr($attr, '.', true); // get attr name
                    $attrArray = trim(strstr($attr, '.'), '.'); // get dot-based array path

                    $defaultValue = new DotData($defaultAttr); // load default attr

                    $dotData = new DotData($this->{$attrName}); // load local attr variable
                    $dotData->set($attrArray, $defaultValue->get($attr)); // set to local prop. variable default value

                    $this->{$attrName} = $dotData->export(); // export to model
                } else {
                    $this->{$attr} = $defaultAttr[$attr]; // just set ;)
                }
                // add message about wrong attribute to session holder, later display it
                $attrLabel = $attr;
                if ($this->getLabel($attr) !== null) {
                    $attrLabel = $this->getLabel($attr);
                }

                App::$Session->getFlashBag()->add('warning', __('Field "%field%" is incorrect', ['field' => $attrLabel]));
            }
        }

        return $success;
    }
112784
public function getTokens() : array
    {
        return [
            'T_N' => self::T_N,
            'T_I' => self::T_I,
            'T_V' => self::T_V,
            'T_X' => self::T_X,
            'T_L' => self::T_L,
            'T_C' => self::T_C,
            'T_D' => self::T_D,
            'T_M' => self::T_M,
        ];
    }
164703
public function validate(): array
	{
		if($this->isInvalid())
		{
			throw new ValidationException($this->errors, 'Invalid input.');
		}

		$validated = [];

		foreach(array_keys($this->ruleSets) as $validatedKey)
		{
			if(Arr::has($this->input, $validatedKey))
			{
				Arr::set($validated, $validatedKey, Arr::get($this->input, $validatedKey));
			}
		}

		return $validated;
	}
164586
public function getStaticTokens()
    {
        $tokens = [];
        $sites = [];
        if (!$this->getValid()) {
            return $sites;
        }
        foreach ($this->xml->children() as $child) {
            if ($child->getName() == "token") {
                $token = $this->parseToken($child);
                if ($token !== false) {
                    $tokens[$token['token']] = $token;
                }
            }
        }
        return $tokens;
    }
1018072
public function validated(): array
    {
        $rules = $this->container->call([$this, 'rules']);

        return $this->only(collect($rules)->keys()->map(function ($rule) {
            return str_contains($rule, '.') ? explode('.', $rule)[0] : $rule;
        })->unique()->toArray());
    }
57378
public function getTokens(): array
    {
        $response = $this
            ->httpClient
            ->get(
                sprintf(
                    '/%s/tokens',
                    $this->getAppUUID()->getId()
                ),
                'get',
                [],
                [],
                Http::getApisearchHeaders($this)
            );

        self::throwTransportableExceptionIfNeeded($response);

        return array_map(function (array $token) {
            return Token::createFromArray($token);
        }, $response['body']);
    }
854470
private function __validate()
    {
        $blnReturn = true;

        foreach ($this->__elements as $element) {
            if (! $element->isValid()) {
                $blnReturn = false;
                break;
            }
        }

        return $blnReturn;
    }
153822
public function validation()
    {
        $validator = new Validation();
        $validator->add(
            'email',
            new Email([
                'field' => 'email',
                'required' => true,
            ])
        );

        $validator->add(
            'displayname',
            new PresenceOf([
                'field' => 'displayname',
                'required' => true,
            ])
        );

        $validator->add(
            'displayname',
            new Regex([
                'field' => 'displayname',
                'message' => _('Please use alphanumerics only.'),
                'pattern' => '/^[A-Za-z0-9_.-]{1,16}$/',
            ])
        );

        // Unique values
        $validator->add(
            'email',
            new Uniqueness([
                'field' => 'email',
                'message' => _('This email already has an account.'),
            ])
        );

        $validator->add(
            'displayname',
            new Uniqueness([
                'field' => 'displayname',
                'message' => _('The username is already taken.'),
            ])
        );

        return $this->validate($validator);
    }
101522
public function ValidateUserInput()
    {
        $bValid = parent::ValidateUserInput();

        $bValid = ($bValid && $this->CheckIncomingHash(TGlobal::instance()->GetUserData()));

        return $bValid;
    }
1135489
public function getTokenElement()
    {
        $element = $this->getElement($this->_tokenFieldName);

        if (! $element) {
            $tokenLib   = $this->tracker->getTokenLibrary();
            $max_length = $tokenLib->getLength();

            // Veld token
            $element = new \Zend_Form_Element_Text($this->_tokenFieldName);
            $element->setLabel($this->translate->_('Token'));
            $element->setDescription(sprintf($this->translate->_('Enter tokens as %s.'), $tokenLib->getFormat()));
            $element->setAttrib('size', $max_length + 2);
            $element->setAttrib('maxlength', $max_length);
            $element->setRequired(true);
            $element->addFilter($this->tracker->getTokenFilter());
            $element->addValidator($this->tracker->getTokenValidator());

            $this->addElement($element);
        }

        return $element;
    }
366454
public function validateCsrf()
    {
        $tokenService = $this->getServiceLocator()->get(TokenService::SERVICE_ID);

        $tokenName = $tokenService->getTokenName();
        $token = $this->getRequestParameter($tokenName);

        if ( $tokenService->checkToken($token) ) {
            $tokenService->revokeToken($token);
            $newToken = $tokenService->createToken();
            $this->setCookie($tokenName, $newToken, null, '/');
            return true;
        }

        \common_Logger::w('Csrf validation failed');
        throw new \common_exception_Unauthorized();
    }