Waliduje poprawność captcha
@param string $value
@return boolean
15566
public function isValid($value)
    {
        //brak wartości
        if (!$value) {
            return $this->_error(self::INVALID);
        }
        //wartości niezgodne
        if ((new \Mmi\Session\SessionSpace('captcha'))->{$this->getOption('name')} != strtoupper($value)) {
            return $this->_error(self::INVALID);
        }
        return true;
    }
890510
private function getCatpchaValue()
    {
        $captcha = $this->getCaptchaImage();

        if (false === $captcha) {
            return false;
        }

        $image = @imagecreatefromstring($captcha);
        if (!$image) {
            $this->error = 'No se pudo crear imagen desde el captcha';

            return false;
        }

        return $this->getValueCaptchaFromImage($image);
    }
1035736
protected function _gtin($value)
    {
        $barcode = substr($value, 0, -1);
        $sum     = 0;
        $length  = strlen($barcode) - 1;

        for ($i = 0; $i <= $length; $i++) {
            if (($i % 2) === 0) {
                $sum += $barcode[$length - $i] * 3;
            } else {
                $sum += $barcode[$length - $i];
            }
        }

        $calc     = $sum % 10;
        $checksum = ($calc === 0) ? 0 : (10 - $calc);
        if ($value[$length + 1] != $checksum) {
            return false;
        }

        return true;
    }
1316593
public static function isUrl($value)
    {
        return \Myaf\Validator\Rules\UrlValidator::validate('', $value, [], self::getInstance());
    }
1133110
public function isMatcher($value): bool
    {
        if (is_object($value)) {
            if ($value instanceof Matcher) {
                return true;
            }

            foreach ($this->driverIndex as $className => $driver) {
                if (is_a($value, $className)) {
                    return true;
                }
            }
        }

        return false;
    }
497964
protected function _validateIPv6($value) {
        if (strlen($value) < 3) {
            return $value == '::';
        }

        if (strpos($value, '.')) {
            $lastcolon = strrpos($value, ':');
            if (!($lastcolon && $this->_validateIPv4(substr($value, $lastcolon + 1)))) {
                return false;
            }

            $value = substr($value, 0, $lastcolon) . ':0:0';
        }

        if (strpos($value, '::') === false) {
            return preg_match('/\A(?:[a-f0-9]{1,4}:){7}[a-f0-9]{1,4}\z/i', $value);
        }

        $colonCount = substr_count($value, ':');
        if ($colonCount < 8) {
            return preg_match('/\A(?::|(?:[a-f0-9]{1,4}:)+):(?:(?:[a-f0-9]{1,4}:)*[a-f0-9]{1,4})?\z/i', $value);
        }

        // special case with ending or starting double colon
        if ($colonCount == 8) {
            return preg_match('/\A(?:::)?(?:[a-f0-9]{1,4}:){6}[a-f0-9]{1,4}(?:::)?\z/i', $value);
        }

        return false;
    }
842601
public static function saveCaptcha($value, $localFile, $width = 200, $height = 100, $quality = 100)
    {
        $builder = new CaptchaBuilder($value);
        $builder->setTextColor(self::$textColor[0], self::$textColor[1], self::$textColor[2]);
        $builder->setBackgroundColor(self::$backgroundColor[0], self::$backgroundColor[1], self::$backgroundColor[2]);
        $builder->build($width, $height, self::$captchaFont ? self::$captchaFont : null);
        return $builder->save($localFile, $quality);
    }
425589
public static function isUrn($value): bool
    {
        if (!static::isStringCastable($value)) {
            return false;
        }

        // http://tools.ietf.org/html/rfc2141#section-2.1
        // To avoid confusion with the "urn:" identifier, the NID "urn" is
        // reserved and MUST NOT be used
        if (substr((string) $value, 0, 8) === "urn:urn:") {
            return false;
        }

        // http://tools.ietf.org/html/rfc2141
        //
        // <URN> ::= "urn:" <NID> ":" <NSS>
        //
        // <NID> ::= <let-num> [ 1,31<let-num-hyp> ]
        // <let-num-hyp> ::= <upper> | <lower> | <number> | "-"
        // <let-num>     ::= <upper> | <lower> | <number>
        // <upper>       ::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" |
        //                   "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" |
        //                   "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" |
        //                   "Y" | "Z"
        // <lower>       ::= "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" |
        //                   "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" |
        //                   "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" |
        //                   "y" | "z"
        // <number>      ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" |
        //                   "8" | "9"
        //
        // <NSS>         ::= 1*<URN chars>
        // <URN chars>   ::= <trans> | "%" <hex> <hex>
        // <trans>       ::= <upper> | <lower> | <number> | <other> | <reserved>
        // <hex>         ::= <number> | "A" | "B" | "C" | "D" | "E" | "F" |
        //                   "a" | "b" | "c" | "d" | "e" | "f"
        // <other>       ::= "(" | ")" | "+" | "," | "-" | "." |
        //                   ":" | "=" | "@" | ";" | "$" |
        //                   "_" | "!" | "*" | "'"
        //
        // Therefore, these characters are RESERVED for future developments.
        // Namespace developers SHOULD NOT use these characters in unencoded
        // form, but rather use the appropriate %-encoding for each character.
        //
        // In addition, octet 0 (0 hex) should NEVER be used, in either
        // unencoded or %-encoded form.
        $pattern = sprintf(
            '/\Aurn:%s:%s\z/i',
            '[a-z0-9](?:[a-z0-9\-]{1,31})?',
            '(?:[a-z0-9()+,\-.:=@;$_!*\']|%(?:0[a-f1-9]|[a-f1-9][a-f0-9]))+'
        );

        return !!preg_match($pattern, (string) $value);
    }
743726
protected function _verify($value) {
        $queryString = http_build_query([
            'secret'   => $this->_secretKey,
            'response' => $value,
            'remoteIp' => $_SERVER['REMOTE_ADDR']
        ]);

        /**
         * PHP 5.6.0 changed the way you specify the peer name for SSL context options.
         * Using "CN_name" will still work, but it will raise deprecated errors.
         */
        $peerKey = version_compare(PHP_VERSION, '5.6.0', '<') ? 'CN_name' : 'peer_name';
        $context = stream_context_create([
            'http'  => [
                'header'      => "Content-type: application/x-www-form-urlencoded\r\n",
                'method'      => self::POST_METHOD,
                'content'     => $queryString,
                'verify_peer' => true,
                $peerKey      => self::PEER_KEY
            ]
        ]);
        $jsonObject = json_decode(file_get_contents(self::SITE_VERIFY_URL, false, $context));

        return $jsonObject->success;
    }
33846
public function checkPlain($value)
    {
        if (!Type::isStringable($value)) {
            return false;
        }

        $string = "$value";

        return $string == strip_tags($string);
    }
240420
private static function isAssoc($value)
	{
		if(!is_array($value)) return false;
		return array_keys($value) !== range(0, count($value) - 1);
	}
558178
private function detectFromPHPInfo($value)
    {
        $result = null;
        if (is_string($value) && preg_match('/\bApache\/(\d+(\.\d+)+)/i', $value, $m)) {
            $result = $m[1];
        }

        return $result;
    }
1060467
public function isValueValid($value) {
		return $value instanceof Type\ListItemType || $value instanceof DataType\TextType || $value instanceof Type\ThingType;
	}
63590
public static function googleRecaptcha($value, $context)
    {
        $httpClient = new Client();
        $googleReponse = $httpClient->post('https://www.google.com/recaptcha/api/siteverify', [
            'secret' => Configure::read('Google.Recaptcha.secret'),
            'response' => $value,
            'remoteip' => Router::getRequest()->clientIp()
        ]);
        $result = json_decode($googleReponse->body(), true);
        if (!empty($result['error-codes'])) {
            Log::error('Google Recaptcha: ' . $result['error-codes'][0]);
        }
        return (bool)$result['success'];
    }
1255684
public static function getCaptchaData($value, $width = 200, $height = 100, $quality = 100)
    {
        $builder = new CaptchaBuilder($value);
//        $builder->setTextColor(self::$textColor[0], self::$textColor[1], self::$textColor[2]);
//        $builder->setBackgroundColor(self::$backgroundColor[0], self::$backgroundColor[1], self::$backgroundColor[2]);
        $builder->build($width, $height, self::$captchaFont ? self::$captchaFont : null);
        return $builder->get($quality);
    }
107811
public function isValid($value, $context = null)
    {
        if (! is_array($value) && ! is_array($context)) {
            $this->error(self::MISSING_VALUE);
            return false;
        }

        if (! is_array($value) && is_array($context)) {
            $value = $context;
        }

        if (empty($value[$this->responseField])) {
            $this->error(self::MISSING_VALUE);
            return false;
        }

        $service = $this->getService();

        $res = $service->verify($value[$this->responseField]);
        if (! $res) {
            $this->error(self::ERR_CAPTCHA);
            return false;
        }

        if (! $res->isSuccess()) {
            $result = $res->getErrorCodes();
            $this->error(self::BAD_CAPTCHA, end($result));
            return false;
        }

        return true;
    }
1144557
public function formRecaptcha($name, $value = null, $attribs = null, $options = null, $listsep = '')
    {
        if (!isset($attribs['siteKey']) || !isset($attribs['secretKey'])) {
            throw new \Zend_Exception('Site key is not set in the view helper');
        }

        $customClasses = '';
        if( isset( $attribs['classes'] )) {
            if( is_array( $attribs['classes'] ) ) {
                $customClasses = implode(' ', $attribs['classes']);
            } else {
                $customClasses = $attribs['classes'];
            }
        }

        $js = '<script src=\'https://www.google.com/recaptcha/api.js\'></script>';
        $captcha= '<div class="g-recaptcha ' . $customClasses . '" data-sitekey="' . $attribs['siteKey'] . '"></div>';
        return $js . $captcha;
    }