Validates PostCodeLocation against GoogleMaps Serverside

@return String
182249
public function validate($validator){
		$name = $this->name;
		
		$latitudeField = $this->fieldLatitude;
		$longditudeField = $this->fieldLongditude;
		$latitudeField->setValue($_POST[$name]['Latitude']);
		$longditudeField->setValue($_POST[$name]['Longditude']);
                
		// Result was unique
		if($latitudeField->Value() != '' && is_numeric($latitudeField->Value()) && $longditudeField->Value() != '' && is_numeric($longditudeField->Value())){
			return true;
		}
	}
1337890
public function getVerificationCode()
    {
        $code = SiteConfig::current_site_config()->GoogleVerificationCode;
        
        if (!$code) {
            $code = self::config()->verification_code;
        }
        
        return $code;
    }
534420
public function isActiveBillingGoogleAddress()
    {
        $flag = $this->scopeConfig->isSetFlag(
            self::XML_GOOGLE_MAP_ADDRESS_ACTIVE_GOOGLE_ADDRESS_BILLING,
            \Magento\Store\Model\ScopeInterface::SCOPE_STORE
        );
        return $flag && $this->getGoogleMapApiKey();
    }
383923
public static function getClientLocation()
    {
        $result = false;
        $ip_data = @json_decode(self::curl('http://www.geoplugin.net/json.gp?ip='.self::getClientIP()));

        if (isset($ip_data) && $ip_data->geoplugin_countryName != null) {
            $result = $ip_data->geoplugin_city.', '.$ip_data->geoplugin_countryCode;
        }

        return $result;
    }
553389
public function validate()
    {
        return (
            (
                filter_var($this->uri, FILTER_VALIDATE_URL) ||
                // PHP 5.x bug fix: FILTER_VALIDATE_URL doesn't support IPv6 urls. IP check not needed in the future.
                $this->validateIP(($parsed = parse_url($this->uri, PHP_URL_HOST)) === false ? '' : $parsed)
            ) &&
            ($parsed = parse_url($this->uri)) !== false &&
            (
                $this->validateHost($parsed['host']) ||
                $this->validateIP($parsed['host'])
            ) &&
            $this->validateScheme($parsed['scheme'])
        );
    }
327787
private function getCountryCode()
    {
        $posted = $this->appRequest->getPostValue();
        if (isset($posted['customer'][ABlock::TMPL_FLDGRP][ABlock::TMPL_FIELD_COUNTRY_CODE])) {
            $result = $posted['customer'][ABlock::TMPL_FLDGRP][ABlock::TMPL_FIELD_COUNTRY_CODE];
        } else {
            $result = $this->hlpRegistry->getCustomerCountry();
        }
        return $result;
    }
926397
public function validate(){
        if( $this->enabled && ($response = $this->input->request('g-recaptcha-response')) && $this->input->remote_ip() ){
	        $endpoint = sprintf('https://www.google.com/recaptcha/api/siteverify?secret=%s&response=%s&remoteip=%s',
		        constant(self::PRIVATE_KEY), rawurlencode($response), rawurlencode($this->input->remote_ip()));
	        $response = wp_remote_get($endpoint);
	        if( is_wp_error($response) ){
		        return false;
	        }
	        $result = json_decode($response['body']);
	        return isset($result->success) && $result->success;
        }else{
            return false;
        }
    }
1239984
public function validateReceived()
    {
        $this->debugMessage[] = 'IPN VALIDATION: START';
        if (!$this->ipnPostDataCheck()) {
            $this->debugMessage[] = 'IPN VALIDATION: END';
            return false;
        }

        //'ORDERSTATUS'
        $this->logFunc("IPN", $this->postData, @$this->postData['REFNOEXT']);
        if (!in_array(trim($this->postData['ORDERSTATUS']), $this->successfulStatus)) {
            $this->errorMessage[] = 'INVALID IPN ORDER STATUS: ' . $this->postData['ORDERSTATUS'];
            $this->debugMessage[] = 'IPN VALIDATION: END';
            return false;
        }
        $validationResult = false;
        $calculatedHashString = $this->createHashString($this->flatArray($this->postData, array("HASH")));
        if ($calculatedHashString == $this->postData['HASH']) {
            $validationResult = true;
        }
        if ($validationResult) {
            $this->debugMessage[] = 'IPN VALIDATION: ' . 'SUCCESSFUL';
            $this->debugMessage[] = 'IPN CALCULATED HASH: ' . $calculatedHashString;
            $this->debugMessage[] = 'IPN HASH: ' . $this->postData['HASH'];
            $this->debugMessage[] = 'IPN VALIDATION: END';
            return true;
        } elseif (!$validationResult) {
            $this->errorMessage[] = 'IPN VALIDATION: ' . 'FAILED';
            $this->errorMessage[] = 'IPN CALCULATED HASH: ' . $calculatedHashString;
            $this->errorMessage[] = 'IPN RECEIVED HASH: ' . $this->postData['HASH'];
            $this->debugMessage[] = 'IPN VALIDATION: END';
            return false;
        }
        return false;
    }
486604
protected function validateFieldsAddress()
    {
        $this->validateFieldAddress('address_1');
        $this->validateFieldAddress('address_2');
        $this->validateFieldAddress('phone');
        $this->validateFieldAddress('middle_name');
        $this->validateFieldAddress('last_name');
        $this->validateFieldAddress('first_name');
        $this->validateFieldAddress('postcode');
        $this->validateFieldAddress('company');
        $this->validateFieldAddress('fax');
    }
1025266
public function validatePostcode($postcode)
    {
        if (!is_string($postcode)) {
            return null;
        }

        if ($postcode) {
            $postcode = self::clean($postcode);
        }

        // add in space
        if (strlen($postcode) >= 5) {
            $postcode = preg_replace('/([0-9][A-Z][A-Z])$/is', ' $1', $postcode, 1);
        }

        // Aware that this is not the official RegExp as the setters define whether the part is valid
        $regularExpression = self::RxComplete;

        $matches = [];
        preg_match($regularExpression, $postcode, $matches);

        $cMatches = count($matches);

        if ($cMatches) {
            if ($cMatches === 2 && $matches[0]) {
                $this->setPostcodeArea($matches[0]);
            }

            if ($cMatches === 4 && $matches[2] && $matches[3]) {
                $this->setPostcodeArea($matches[3]);
                $this->setPostcodeOutward($matches[2]);
            }

            if ($cMatches === 9 &&
                $matches[4] && $matches[5] && $matches[6] && $matches[7] &&
                in_array($matches[6], self::$postcodeAreas, true)
            ) {
                $this->setPostcode(str_replace(' ', '', $matches[4]));
                $this->setPostcodeArea($matches[6]);
                $this->setPostcodeOutward($matches[5]);
                $this->setPostcodeInward($matches[7]);
                $this->setPostcodeSector($matches[8]);
            }
        }

        return $this->getPostcode();
    }
639046
public function validate_target_location() {

        if (!isset($this->assertions['plugintype'])) {
            throw new coding_exception('Required plugin type must be set before calling this');
        }

        $plugintypepath = $this->get_plugintype_location($this->assertions['plugintype']);

        if (is_null($plugintypepath)) {
            $this->add_message(self::ERROR, 'unknowntype', $this->assertions['plugintype']);
            return false;
        }

        if (!is_dir($plugintypepath)) {
            throw new coding_exception('Plugin type location does not exist!');
        }

        // Always check that the plugintype root is writable.
        if (!is_writable($plugintypepath)) {
            $this->add_message(self::ERROR, 'pathwritable', $plugintypepath);
            return false;
        } else {
            $this->add_message(self::INFO, 'pathwritable', $plugintypepath);
        }

        // The target location itself may or may not exist. Even if installing an
        // available update, the code could have been removed by accident (and
        // be reported as missing) etc. So we just make sure that the code
        // can be replaced if it already exists.
        $target = $plugintypepath.'/'.$this->rootdir;
        if (file_exists($target)) {
            if (!is_dir($target)) {
                $this->add_message(self::ERROR, 'targetnotdir', $target);
                return false;
            }
            $this->add_message(self::WARNING, 'targetexists', $target);
            if ($this->get_plugin_manager()->is_directory_removable($target)) {
                $this->add_message(self::INFO, 'pathwritable', $target);
            } else {
                $this->add_message(self::ERROR, 'pathwritable', $target);
                return false;
            }
        }

        return true;
    }
1234547
public static function postcode($value)
    {
        $bool = preg_match(self::$regularExpressions['postcode'], $value);

        if (!$bool) {
            return false;
        }

        return true;
    }
971758
protected function validateCodeCurrency()
    {
        $field = 'code';

        if ($this->isExcluded($field)) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if ($this->isUpdating() && !isset($value)) {
            $this->unsetSubmitted($field);
            return null;
        }

        $label = $this->translation->text('Code');

        if (empty($value)) {
            $this->setErrorRequired($field, $label);
            return false;
        }

        if (preg_match('/^[a-zA-Z]{3}$/', $value) !== 1) {
            $this->setErrorInvalid($field, $label);
            return false;
        }

        $code = strtoupper($value);
        $updating = $this->getUpdating();

        if (isset($updating['code']) && $updating['code'] === $code) {
            return true;
        }

        $existing = $this->currency->get($code);

        if (!empty($existing)) {
            $this->setErrorExists($field, $label);
            return false;
        }

        $this->setSubmitted($field, $code);
        return true;
    }
185189
protected function validateBasepathStore()
    {
        $field = 'basepath';

        if ($this->isExcluded($field) || $this->isError('domain')) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if ($this->isUpdating() && !isset($value)) {
            $this->unsetSubmitted($field);
            return null;
        }

        if ($this->getSubmitted('default')) {
            $this->unsetSubmitted($field);
            return null; // Cannot update basepath of default store
        }

        $updating = $this->getUpdating();

        if (isset($updating['basepath'])
            && $updating['basepath'] === $value
            && $updating['domain'] === $this->getSubmitted('domain')) {
            return true;
        }

        if (preg_match('/^[a-z0-9-]{0,50}$/', $value) !== 1) {
            $this->setErrorInvalid($field, $this->translation->text('Path'));
            return false;
        }

        return true;
    }
388202
public function searchLocations($cityNameOrPostalCode)
    {
        $normalize = $this->removeAccents($cityNameOrPostalCode);
        $normalize = Regex::replace("/[^A-Za-z0-9\s]/", '', $normalize)->result();
        $normalize = strtolower($normalize);
        $normalize = substr($normalize, 0, 2);

        $url = "/etc/designs/meteoswiss/ajax/search/$normalize.json";

        $result = collect($this->makeRequest($url, true));

        $result = $result->map(function ($r) {
            list($locationId, $canton, $u1, $postalCode, $u2, $cityName) = explode(';', $r);

            return [
                'location_id' => $locationId,
                'canton' => $canton,
                'postal_code' => $postalCode,
                'city_name' => $cityName,
            ];
        })->filter(function ($m) use ($cityNameOrPostalCode) {
            return str_contains(strtolower($m['city_name']), strtolower($cityNameOrPostalCode)) || str_contains($m['postal_code'], $cityNameOrPostalCode);
        });

        return $result;
    }
206071
protected function validateDestinationRename()
    {
        if ($this->isError()) {
            return null;
        }

        $files = $this->getSubmitted('files');

        /* @var $file \SplFileInfo */
        $file = reset($files);
        $name = $this->getSubmitted('name');

        $directory = dirname($file->getRealPath());
        $destination = gplcart_path_normalize("$directory/$name");

        if (file_exists($destination)) {
            $this->setError('name', $this->translation->text('Destination already exists'));
            return false;
        }

        $this->setSubmitted('destination', $destination);
        return true;
    }
261527
protected function validatePaymentAddressOrder()
    {
        $field = 'payment_address';

        if ($this->isExcluded($field)) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if (!isset($value) && $this->isUpdating()) {
            $this->unsetSubmitted($field);
            return null;
        }

        if (empty($value) && !$this->isError('shipping_address')) {
            $value = $this->getSubmitted('shipping_address');
        }

        $label = $this->translation->text('Payment address');

        if (empty($value)) {
            $this->setErrorRequired($field, $label);
            return false;
        }

        if (!is_numeric($value)) {
            $this->setErrorNumeric($field, $label);
            return false;
        }

        $address = $this->address->get($value);

        if (empty($address)) {
            $this->setErrorUnavailable($field, $label);
            return false;
        }

        $this->setSubmitted($field, $value);
        return true;
    }