Validates the input to see if it matches the generated code.
@param string $input user input
@param bool $caseSensitive whether the comparison should be case-sensitive
@return bool whether the input is valid
171188
public function validate(string $input, bool $caseSensitive): bool
    {
        $code = $this->getVerifyCode();
        $valid = $caseSensitive ? ($input === $code) : strcasecmp($input, $code) === 0;
        $session = $this->getApp()->getSession();
        $session->open();
        $name = $this->getSessionKey() . 'count';
        $session[$name] += 1;
        if ($valid || $session[$name] > $this->testLimit && $this->testLimit > 0) {
            $this->getVerifyCode(true);
        }

        return $valid;
    }
925133
protected function convertToSnakeCase($input)
    {
        if ($this->convertToSnakeCaseIsDisabled()) {
            return;
        }

        if (is_null($input)) {
            return null;
        } elseif (is_array($input)) {
            return $this->convertArrayToSnakeCase($input);
        }

        return snake_case($input);
    }
82432
public function validate( $input )
    {
        // Check for minimum constraint
        if ( ( $this->min !== false ) &&
             ( $input < $this->min ) )
        {
            throw new phpillowValidationException(
                'Input value %input is not bigger or equal then %minimum.',
                array(
                    'input'   => $input,
                    'minimum' => $this->min,
                )
            );
        }

        // Check for maximum constraint
        if ( ( $this->max !== false ) &&
             ( $input > $this->max ) )
        {
            throw new phpillowValidationException(
                'Input value %input is not lesser or equal then %maximum.',
                array(
                    'input'   => $input,
                    'maximum' => $this->max,
                )
            );
        }

        return (int) $input;
    }
991300
public function validate( $input )
    {
        // Check if passed input is an object and instance of phpillowDocument
        // at all, otherwise we can exit immediately
        if ( !is_object( $input ) ||
             !( $input instanceof phpillowDocument ) )
        {
            throw new phpillowValidationException( 'Invalid document type provided.', array() );
        }

        // If a specific document class is required, check this type is passed,
        // otherwise throw an exception.
        if ( ( $this->documentClass !== false ) &&
             !( $input instanceof $this->documentClass ) )
        {
            throw new phpillowValidationException( 'Invalid document type provided.', array() );
        }

        // Check if the document already has an ID assigned, otherwise it has
        // not yet been stored in the database and though is invalid.
        if ( $input->_id === null )
        {
            throw new phpillowValidationException( 'Invalid document type provided.', array() );
        }

        // If all above checks has been passed just return the document ID,
        // because that is all we need to store in database.
        return $input->_id;
    }
1015636
private function validateStatementClass(array $input)
    {
        if (!isset($input[0])) {
            Exception::newStatementClassException();
        }

        $statementClass = $input[0];

        if (!class_exists($statementClass)) {
            Exception::newStatementClassException();
        }

        return $statementClass;
    }
257758
public static function isEnd($haystack, $needle, $caseSensitive = false): bool
    {
        if ($caseSensitive) {
            return $needle === '' || self::sub($haystack, -self::len($needle)) === $needle;
        }

        $haystack = self::low($haystack);
        $needle = self::low($needle);

        return $needle === '' || self::sub($haystack, -self::len($needle)) === $needle;
    }
47440
public static function replace($search, $replace, $string, $caseSensitive = true)
    {
        if (!self::isValid($replace)) {
            return false;
        }

        if (!$caseSensitive) {
            return str_ireplace($search, $replace, $string);
        } else {
            return str_replace($search, $replace, $string);
        }
    }
521324
public function validate($input, $rules = [])
  {
    $rules = $rules ?: $this->getRules();

    $validator = $this->validator->make($input, $rules);

    if ($validator->fails()) throw new ValidationException($validator->messages(), 'Validation failed.');

    return true;
  }
375242
public function matched($input)
    {
        if ($this->token instanceof Token) {
            return $this->token->matched($input);
        }
        
        return $input;
    }
17430
public function validate($input)
    {
        switch (strlen($input)) {
            // YYMMDDAABB
            case 10:
                $parsed = $input;
                break;

            case 11: // YYMMDD[-+]AABB
                $parsed = str_replace(array('-', '+'), '', $input);
                break;

            // YYYYMMDDAABB
            case 12:
                $parsed = substr($input, 2);
                break;

            case 13: // YYYYYYMMDD[-+]AABB
                $parsed = substr($input, 2);
                $parsed = str_replace(array('-', '+'), '', $parsed);
                break;

            default:
                return false;
        }

        if (!preg_match('/^\d+$/', $parsed)) {
            return false;
        }

        // Use DateTime to parse the date and see if it changes
        $date     = substr($parsed, 0, 6);
        $dateTime = \DateTime::createFromFormat('ymd', $date);

        // If it changes, it wasn't a valid date (since 991232 will yield 000101)
        if ($dateTime->format('ymd') !== $date) {
            return false;
        }

        // Get check number
        $check  = intval(substr($parsed, -1, 1));
        $parsed = substr($parsed, 0, 9);

        $result = 0;

        // Calculate check number
        for ($i = 0; $i < strlen($parsed); $i++) {

            if (($i % 2) == 0) {
                $number = intval($parsed[$i] * 2);
            } else {
                $number = intval($parsed[$i]);
            }

            if ($number > 9) {
                $result += (1 + ($number % 10));
            } else {
                $result += $number;
            }
        }

        return ((($check + $result) % 10) == 0);
    }
43731
public static function startsWith($string, $target, $caseSensitive = true)
    {
        if (!$caseSensitive) {
            $string = strtolower($string);
            $target = strtolower($target);
        }

        return strpos($string, $target) === 0;
    }
1248158
public function contains($str, $cs = CaseSensitivity::CASE_SENSITIVE)
    {
        $text = (string)$this->text;
        $s = (string)$str;

        switch ($cs) {
            case CaseSensitivity::CASE_SENSITIVE:
                $result = strpos($text, $s);
                break;
            case CaseSensitivity::CASE_INSENSITIVE:
                $result = stripos($text, $s);
                break;
            default:
                throw new MWrongTypeException("\$cs", "CaseSensitivity", $cs);
                break;
        }

        return ($result !== false);
    }
1361734
public function match($input)
    {
        // Match the input with the regex pattern, storing any match found into the $matches variable,
        // along with the index of the string at which it was matched.
        $result = preg_match($this->pattern, $input, $matches, PREG_OFFSET_CAPTURE);

        // preg_match returns false if an error occured
        if ($result === false)
            throw new \Exception(preg_last_error());

        // 0 means no match was found
        if ($result === 0)
            return null;

        return $this->getTokenFromMatch($matches[0]);
    }
178827
public function match($input)
    {
        if (!is_string($input)) {
            throw new \InvalidArgumentException(
                'Invalid argument. Expected a string, received ' . gettype($input)
            );
        }

        return (bool) preg_match('/' . $this->getRule() . '/ms', strtolower($input));
    }
14451
protected function validateInput($input)
    {
        // check
        $keys = [
            'form',
            'elements',
        ];

        switch (gettype($input)) {
            case 'array':
                foreach ($keys as $key) {
                    if (array_key_exists($key, $input) === false) {
                        throw new \Exception(
                            'Input invalid! Please make sure that input array contains keys (form, elements).'
                        );
                    }
                }
                break;
        }

        return true;
    }
1222881
protected function validate(string $input): bool
    {
        return \Normalizer::isNormalized($input, \Normalizer::FORM_KC)
            && ($this->isRegExp($input) ? $this->validateRegexp($input) : $this->validateCharacters($input));
    }
139898
private function _validateInput($input, $base, $checkDomain = false)
    {
        if (!array_key_exists($base, self::$allowedBases)) {
            throw new InvalidArgumentException(sprintf(
                'Type must be one of "%s".',
                implode(', ', array_keys(self::$allowedBases))
            ));
        }

        if (preg_match(self::$allowedBases[$base], $input) !== 1) {
            throw new InvalidArgumentException(sprintf(
                'Input data "%s" does not match pattern "%s".',
                $input,
                self::$allowedBases[$base]
            ));
        }

        if ($checkDomain) {
            $compare = gmp_init($input, $base);

            if (gmp_cmp($this->minValue, $compare) > 0 || gmp_cmp($compare, $this->maxValue) > 0) {
                throw new InvalidArgumentException(sprintf(
                    'Input value "%d" is out of domain range "%d - %d".',
                    gmp_strval($compare, 10),
                    $this->minValue,
                    $this->maxValue
                ));
            }
        }
    }