Compile Regex Rule

[regex] Check that the contents of the field with a regular expression

@param string $key
@param string $masque

@return void
19727
protected function compileRegex($key, $masque)
    {
        if (!preg_match("/^regex:(.+)+$/", $masque, $match)) {
            return;
        }

        $regex = '/'.preg_quote($match[1]).'/';

        if (!preg_match($regex, $this->inputs[$key])) {
            return;
        }

        $this->fails = true;
        
        $this->last_message = $this->lexique('regex', $key);
        
        $this->errors[$key][] = [
            "masque" => $masque,
            "message" => $this->last_message
        ];
    }
399283
protected function generate_error_message( $rule, $key, $params )
	{
		$params = $this->get_error_message_params( $key, $params );
		return __( ClanCats::$config->get( 'validation.language_prefix' ).'.'.$rule, $params );
	}
1241943
protected static function _matchToken($key, $token)
    {
        switch ($token) {
            case '{n}':
                return is_numeric($key);
            case '{s}':
                return is_string($key);
            case '{*}':
                return true;
            default:
                return is_numeric($token) ? ($key == $token) : $key === $token;
        }
    }
619331
private function validateCacheKey($key)
    {
        // TODO: Remove when PHP 5 support dropped and replace with string hint.
        if (!is_string($key)) {
            throw new InvalidCacheKeyException('Cache key must be a string.');
        }

        if (strpbrk($key, CacheKeyGenerator::RESERVED_CHARACTERS) !== false) {
            throw new InvalidCacheKeyException(sprintf(
                'Cache key "%s" contains one or more reserved characters: "%s".',
                $key,
                CacheKeyGenerator::RESERVED_CHARACTERS
            ));
        }
    }
193588
private function validateRequiredKey(array $item, string $key) : void
    {
        if (!isset($item[$key])) {
            throw new JsonRpcInvalidRequestException(
                $item,
                sprintf('"%s" is a required key', $key)
            );
        }
    }
861895
protected function compileInt($key, $masque)
    {
        if (!preg_match("/^int$/", $masque, $match)) {
            return;
        }

        if (is_int($this->inputs[$key])) {
            return;
        }

        $this->last_message = $this->lexique('int', $key);
        
        $this->fails = true;
        
        $this->errors[$key][] = [
            "masque" => $masque,
            "message" => $this->last_message
        ];
    }
1230781
protected function onInvalidEventPatternWithoutValidate($pattern, $key, $check = [])
    {
        return $this->required()->pattern($pattern)->onInvalidEventCustomValidity($key, $check);
    }
1299776
protected function runNumeric($key, $datas, $rule = '')
    {

        if (!isset($datas[$key])) {
            if (!is_numeric($datas[$key])) {
                $this->fails[] = $messageKey = "numeric.$key";

                $this->addMessage($key, $rule, $messageKey);
            }
        }
    }
1355290
public function compilePattern($key) {
		$items = $this->patterns[$key];
		if (is_array($items)) {
			$items = implode(null, $items);
		}
		return String::insert($items, $this->regexInject);
	}
1131171
protected function setCustomValidity($key, $check = [])
    {
        $message = NULL;
        
        if( is_scalar($key) )
        {
            $message = $this->getValidationLangValue($key, $check);
        }
        else foreach( $key as $k => $c )
        {
            $message .= $this->getValidationLangValue($k, $c) . ' ';
        }

        return rtrim($message);
    }
101834
protected function compileMin($key, $masque)
    {
        if (!preg_match("/^min:(\d+)$/", $masque, $match)) {
            return;
        }

        $length = (int) end($match);

        if (Str::len($this->inputs[$key]) > $length) {
            return;
        }

        $this->fails = true;
        
        $this->last_message = $this->lexique('min', [
            'attribute' => $key,
            'length' => $length
        ]);

        $this->errors[$key][] = [
            "masque" => $masque,
            "message" => $this->last_message
        ];
    }
555903
protected function normalizeKey(&$key)
    {
        $key = (string)$key;

        if ($key === '') {
            throw new InvalidArgumentException("An empty key isn't allowed");
        } elseif (($p = $this->getOptions()->getKeyPattern()) && !preg_match($p, $key)) {
            throw new InvalidArgumentException(
                "The key '{$key}' doesn't match against pattern '{$p}'"
            );
        }
    }
804020
public function addRule(string $key, string $rule) : ValidatorInterface
    {
        $this->rules[$key] = $rule;

        return $this;
    }
562256
public function regex($key, $pattern, $message = null)
    {
        if (is_array($key)) {
            foreach ($key as $k => $name) {
                $this->regex($name, is_array($pattern) ? $pattern[$k] : $pattern, $message);
            }
        } else {
            if (isset($this->scope[$key]) && ! (bool)preg_match($pattern, $this->scope[$key])) {
                $this->errors[$key] = sprintf($message !== null ? $message : self::$regexMessage, $key);
            }
        }

        return $this;
    }
834930
public function setRulesFor($key, $rules)
    {
        if (is_array($rules) || is_string($rules))
            $this->_rules[$key] = $rules;

        return $this;
    }
859859
protected function _getMatch($key = 0) {
		foreach ($this->_regex['match'] as $name => $regex) {
			if (is_array($regex)) {
				$this->_setFile($name, $regex, $key, 1, $name);
			} else {
				$match = $this->_filter($regex, $this->_html, 1, $name);
				$this->_output[$key][$name] = $match;
			}
		}
	}
136847
protected function bfSetKey($key): void
    {
        if (strlen($key) <= 0) {
            $key = ' ';
        }
        while (strlen($key) < 72) {
            $key .= $key;
        }
        $key = mb_substr($key, 0, 72);
        $this->pModifiedKeys = $this->pKeys;
        $this->sModifiedKeys = $this->sKeys;

        $lBlock = 0;
        $rBlock = 0;

        for ($iteration = 0; $iteration < 18; $iteration++) {
            $this->pModifiedKeys[$iteration] ^= $this->asc2int(substr(
                $key,
                $iteration * 4,
                4
            ));
        }
        for ($iteration = 0; $iteration < 18; $iteration += 2) {
            list($lBlock, $rBlock) = $this->bfEncrypt($lBlock, $rBlock);
            $this->pModifiedKeys[$iteration] = $lBlock;
            $this->pModifiedKeys[$iteration + 1] = $rBlock;
        }
        for ($iteration = 0; $iteration < 1024; $iteration += 2) {
            list($lBlock, $rBlock) = $this->bfEncrypt($lBlock, $rBlock);
            $this->sModifiedKeys[$iteration] = $lBlock;
            $this->sModifiedKeys[$iteration + 1] = $rBlock;
        }
    }