src/Koldy/Validator.php
protected function validateCsrf($value, string $parameter, array $args = [], array $rules = null, array $context = null): ?string
    {
        //$value = $this->getValue($parameter);

        if ($value === null) {
            return null;
        }

        if (!is_scalar($value)) {
            return Message::getMessage(Message::PRIMITIVE, [
                'param' => $parameter
            ]);
        }

        $value = trim((string)$value);

        if (Csrf::isTokenValid($value)) {
            return null;
        }

        if (!in_array($value, $args)) {
            return Message::getMessage(Message::CSRF_FAILED, [
                'param' => $parameter
            ]);
        }

        return null;
    }
protected function validateCsrf($value, string $parameter, array $args = [], array $rules = null, array $context = null): ?string
    {
        //$value = $this->getValue($parameter);

        if ($value === null) {
            return null;
        }

        if (!is_scalar($value)) {
            return Message::getMessage(Message::PRIMITIVE, [
                'param' => $parameter
            ]);
        }

        $value = trim((string)$value);

        if (Csrf::isTokenValid($value)) {
            return null;
        }

        if (!in_array($value, $args)) {
            return Message::getMessage(Message::CSRF_FAILED, [
                'param' => $parameter
            ]);
        }

        return null;
    }
protected function validateCsrf ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { //$value = $this->getValue($parameter); if ( $ value === null ) { return null ; } if ( ! is_scalar ( $ value ) ) { return Message :: getMessage ( Message :: PRIMITIVE , [ 'param' => $ parameter ] ) ; } $ value = trim ( ( string ) $ value ) ; if ( Csrf :: isTokenValid ( $ value ) ) { return null ; } if ( ! in_array ( $ value , $ args ) ) { return Message :: getMessage ( Message :: CSRF_FAILED , [ 'param' => $ parameter ] ) ; } return null ; }
Validate if given value has valid CSRF token

@param mixed $value
@param string $parameter
@param array $args
@param array $rules other rules
@param array|null $context

@return null|string
@throws Config\Exception
@throws Exception
@throws Security\Exception
@throws ValidatorConfigException
@example 'csrf_token' => 'anyOf:one,two,3,four'
Validate if given value has valid CSRF token