验证输入，看看它是否与生成的代码相匹配
@param string $input user input
@param boolean $caseSensitive whether the comparison should be case-sensitive
@return boolean whether the input is valid
168534
public function validate($input, $caseSensitive)
    {
        $code = $this->getVerifyCode();
        $valid = $caseSensitive ? ($input === $code) : strcasecmp($input, $code) === 0;

        $count = $this->cache->get($this->sessionKey . 'count');
        $count = $count + 1;
        if ($valid || $count > $this->testLimit && $this->testLimit > 0) {
            $this->getVerifyCode(true);
        }
        //更新计数器
        $this->cache->set($this->sessionKey . 'count', $count, $this->duration);
        return $valid;
    }
1016464
public static function camelCase(string $input)
    {
        $words = __::words(preg_replace("/['\x{2019}]/u", '', $input));

        return array_reduce(
            $words,
            function ($result, $word) use ($words) {
                $isFirst = __::first($words) === $word;
                $word = __::toLower($word);

                return $result . (!$isFirst ? __::capitalize($word) : $word);
            },
            ''
        );
    }
109324
public function validate($input): bool
    {
        // for array
        if (\is_array($input)) {
            return \in_array($this->containsValue, $input, false);
        }
        // for string
        if (\is_string($input)) {
            return false !== mb_stripos($input, $this->containsValue, 0, mb_detect_encoding($input));
        }
        // can't compare
        return false;
    }
1260822
protected function createWrapCase(bool $caseSensitive): \Closure
    {
        return function (string $expr) use ($caseSensitive): string {
            if ($caseSensitive) {
                return $expr;
            }

            return sprintf('LOWER(%s)', $expr);
        };
    }
799138
public function match($input)
    {
        if ($this->token instanceof Token) {
            if ($this->token->matches($input)) {
                return true;
            }
            return false;
        }
        
        if ($this->token === $input) {
            return true;
        }
        return false;
    }
327984
public static function fromStrValue($value, $caseInsensitive = false)
    {
        foreach (static::values() as $key => $enumInstance) {
            if (is_string($enumInstance->getValue())) {
                if (!$caseInsensitive && $enumInstance->getValue() === $value) {
                    return $enumInstance;
                }

                if ($caseInsensitive && strcasecmp($enumInstance->getValue(), $value) === 0) {
                    return $enumInstance;
                }
            }
        }

        return null;
    }
1147465
function(input) {
		var needstesting = !this._matches.length;
		if (needstesting || this._matches.every(function(match) {
			return match.$instanceid !== input.$instanceid;
		})) {
			return this._maybeinput(input);
		}
		return false;
	}
1154717
public function endsWith($string, bool $caseInsensitive = false): bool
    {
        try {
            Assert::typeOf(['string', __CLASS__], $string);
        } catch (InvalidArgumentException|TypeError $t) {
            return false;
        }

        $value  = (string) $string;
        $strLen = mb_strlen($value, $this->encoding);
        $length = $this->length();

        if ($strLen > $length) {
            return false;
        }

        return substr_compare($this->data, $value, $length - $strLen, $length, $caseInsensitive) === 0;
    }
728364
protected function isString($input)
    {
        return is_scalar($input) || is_null($input) || (is_object($input) && method_exists($input, '__toString'));
    }
333463
public static function strIs($patterns, $subject, &$matchedPattern = '', $caseSensitive = false)
    {
        if (!is_array($patterns)) {
            $patterns = (array) $patterns;
        }

        $lowerSubject = strtolower($subject);

        foreach ($patterns as $pattern) {

            if ($caseSensitive) {
                if (str_is($pattern, $subject)) {
                    $matchedPattern = $pattern;
                    return true;
                }
            } else {
                $lowerPattern = strtolower($pattern);
                if (str_is($lowerPattern, $lowerSubject)) {
                    $matchedPattern = $pattern;
                    return true;
                }
            }

        }

        return false;
    }
796882
protected function regexPatternForIs($wildcards, $caseSensitive)
	{
		$pattern = Regex::quote($this->str);

		if($wildcards)
			$pattern = str_replace('\*', '.*', $pattern);

		return $this->newRegex('\A'. $pattern . '\z', ($caseSensitive ?'': Modifiers::CASELESS));
	}
283466
public function verifySalt($input)
    {
        $regex = '/^\$' . $this->_identifier . '\$(?:rounds=(\d{4,9})\$)?([\.\/0-9A-Za-z]{0,16})\$?$/';
        $matches = array ();

        $appearsValid = (1 === preg_match($regex, $input, $matches));
        if ($appearsValid) {
            $rounds = (int) $matches[1];
            $salt = $matches[2];

            // If rounds parameter is in the salt position, the configuration
            // is probably not what the user intends. We could let it pass and
            // it'll "work", but we'll fail it for now.
            if (strpos($salt, 'rounds=') === 0) {
                $appearsValid = false;
            }

            if (!empty ($matches[1]) && ($rounds < 1000 || $rounds > 999999999)) {
                $appearsValid = false;
            }
        }

        return $appearsValid;
    }
1243508
private function validateInput(InputInterface $input)
    {
        if (!$input->getOption('grep')) {
            foreach (['invert', 'insensitive'] as $option) {
                if ($input->getOption($option)) {
                    throw new RuntimeException('--' . $option . ' does not make sense without --grep');
                }
            }
        }
    }
299538
public function match($input)
    {
       
        $noMatch = true;
        foreach ($this->matchers as $matcher) {
            if ($matcher->noMatch()) {
                continue;
            }
            if ($matcher->match($input)) {
                $noMatch = false;
            }
            if ($matcher->matchFound()) {
                $this->matched[] = $matcher->matched;
                $this->resetMatchers();
                break;
            }
        }
        if ($noMatch) {
            return false;
        }
        return true;
    }
1235278
public function getType($input)
    {
        // Make an array to loop through
        $inputs = explode('|', $input);

        foreach ($inputs as $index => $input) {
            $list = (bool) preg_match('/\[\]$/', $input);
            if ($list === true) {
                $input = substr($input, 0, -2);
            }

            // make the type case insensitive
            $type = strtolower(trim($input));

            // Check if we can convert the type to a known type
            if (array_key_exists($type, $this->phpTypeMapping) === true) {
                $type = $this->phpTypeMapping[$type];
            }

            // Check if it is a predefined type
            if (in_array($type, $this->phpTypes) === true) {
                $inputs[$index] = $type . ($list ? '[]' : '');
                continue;
            }

            // Reset the type. Maybe it is a class definition
            $type = $input;

            if (
                $this->isClassDefined($type) === true ||
                $this->isInterfaceDefined($type) === true ||
                $this->isTraitDefined($type) === true
            ) {
                $inputs[$index] = $type . ($list ? '[]' : '');
                continue;
            }

            throw Exception\Type::isNotDefined($type);
        }

        return implode('|', $inputs);
    }
861109
private function convert($input)
    {
        if (is_array($data = json_decode($input, true))) {
            if (array_key_exists('signatures', $data) || array_key_exists('recipients', $data)) {
                $this->log(LogLevel::DEBUG, 'The input seems to be a JWS or a JWE.');

                return $data;
            } elseif (array_key_exists('signature', $data)) {
                $this->log(LogLevel::DEBUG, 'The input seems to be a flattened JWS.');

                return $this->fromFlattenedSerializationSignatureToSerialization($data);
            } elseif (array_key_exists('ciphertext', $data)) {
                $this->log(LogLevel::DEBUG, 'The input seems to be a flattened JWE.');

                return $this->fromFlattenedSerializationRecipientToSerialization($data);
            }
        } elseif (is_string($input)) {
            $this->log(LogLevel::DEBUG, 'The input may be a compact JWS or JWE.');

            return $this->fromCompactSerializationToSerialization($input);
        }
        $this->log(LogLevel::ERROR, 'The input is not supported');
        throw new \InvalidArgumentException('Unsupported input');
    }
1011414
public function ok(&$input): bool
    {
        $input = trim((string) $input);
        $inputLabel = trim($this->fieldLabel ?: 'Field');

        // check required issue
        if ($input === '' && $this->isRequired) {
            $this->fail = sprintf('%s is required.', $inputLabel);
            return false;
        }

        // assing default to input but do not return
        // true to check also given default
        if ($input === '') {
            $input = $this->fieldDefault;
        }

        // skip if null given as default
        // that also checks given default
        if ($input === null && !$this->isRequired) {
            return true;
        }

        // valide by field type
        switch ($this->fieldType) {
            case Validation::TYPE_INT:
            case Validation::TYPE_FLOAT:
                if (!is_numeric($input)) {
                    $this->fail = sprintf('%s value must be type of %s.', $inputLabel, $this->fieldType);
                    return false;
                }

                // sanitize
                $input = ($this->fieldType == Validation::TYPE_INT) ? intval($input) : floatval($input);

                // make unsigned
                if ($this->isUnsigned) {
                    $input = abs($input);
                }

                // check limit(s)
                if ($this->limit !== null) {
                    if (is_numeric($this->limit) && strval($input) !== strval($this->limit)) {
                        $this->fail = sprintf('%s value could be only %s.', $inputLabel, $this->limit);
                        return false;
                    }
                    if ($this->limitMin !== null && $input < $this->limitMin) {
                        $this->fail = sprintf('%s value could be minimum %s.', $inputLabel, $this->limitMin);
                        return false;
                    }
                    if ($this->limitMax !== null && $input > $this->limitMax) {
                        $this->fail = sprintf('%s value could be maximum %s.', $inputLabel, $this->limitMax);
                        return false;
                    }
                }
                break;
            case Validation::TYPE_NUMERIC:
                if (!is_numeric($input)) {
                    $this->fail = sprintf('%s value must be numeric.', $inputLabel);
                    return false;
                }
                // make unsigned
                if ($this->isUnsigned) {
                    $input = abs($input);
                }
                break;
            case Validation::TYPE_STRING:
                // check regexp if provided
                if ($this->specType == 'regexp' && !preg_match($this->spec, $input)) {
                    $this->fail = sprintf('%s value did not match with given pattern.', $inputLabel);
                    return false;
                }

                // check limit(s)
                if ($this->limit !== null) {
                    $isNumericLimit = is_numeric($this->limit);
                    // should truncate?
                    if ($this->isFixed) {
                        $input = mb_substr($input, 0, intval($isNumericLimit ? $this->limit : $this->limitMax));
                    }

                    $inputLength = strlen($input);
                    if ($isNumericLimit && $inputLength !== $this->limit) {
                        $this->fail = sprintf('%s value length must be %s.', $inputLabel, $this->limit);
                        return false;
                    }
                    if ($this->limitMin !== null && $inputLength < $this->limitMin) {
                        $this->fail = sprintf('%s value minimum length could be %s.', $inputLabel, $this->limitMin);
                        return false;
                    }
                    if ($this->limitMax !== null && $inputLength > $this->limitMax) {
                        $this->fail = sprintf('%s value maximum length could be %s.', $inputLabel, $this->limitMax);
                        return false;
                    }
                }
                break;
            case Validation::TYPE_BOOL:
                // set default bool spec
                if ($this->specType != 'array') {
                    $this->spec = ['true', 'false'];
                }

                if (!in_array($input, $this->spec)) {
                    $this->fail = sprintf('%s value could be one of %s options.', $inputLabel, join(', ', $this->spec));
                    return false;
                }
                break;
            case Validation::TYPE_ENUM:
                // @todo Multi-arrays?
                if (!in_array($input, $this->spec)) {
                    $this->fail = sprintf('%s value could be one of %s options.', $inputLabel, join(', ', $this->spec));
                    return false;
                }
                break;
            case Validation::TYPE_EMAIL:
                if (!filter_var($input, FILTER_VALIDATE_EMAIL)) {
                    $this->fail = sprintf('%s value must be a valid email address.', $inputLabel);
                    return false;
                }
                break;
            case Validation::TYPE_DATE:
            case Validation::TYPE_DATETIME:
                if ($this->specType == 'regexp' && !preg_match($this->spec, $input)) {
                    $this->fail = sprintf('%s value did not match with given pattern.', $inputLabel);
                    return false;
                }

                if ($input != date($this->spec, strtotime($input))) {
                    $this->fail = sprintf('%s value is not valid date/datetime.', $inputLabel);
                    return false;
                }
                break;
            case Validation::TYPE_URL:
                if ($this->specType == 'regexp' && !preg_match($this->spec, $input)) {
                    $this->fail = sprintf('%s value did not match with given pattern.', $inputLabel);
                    return false;
                }
                if ($this->specType == 'array') {
                    // remove silly empty components (eg: path always comes even url is empty)
                    $url = array_filter((array) parse_url($input), 'strlen');
                    $components = [];
                    foreach ($this->spec as $component) {
                        if (!isset($url[$component])) {
                            $components[] = $component;
                        }
                    }
                    if (!empty($components)) {
                        $this->fail = sprintf('%s value is not a valid URL (missing components: %s).',
                            $inputLabel, join(', ', $components));
                        return false;
                    }
                    return true;
                }
                if (!filter_var($input, FILTER_VALIDATE_URL)) {
                    $this->fail = sprintf('%s value is not a valid URL.', $inputLabel);
                    return false;
                }
                break;
        }

        // seems nothing wrong
        return true;
    }