public function isValid($value, $context = null) { if (!empty($value)) { $this->vat = $value; $countryid = intval($context['country_id']); if ($countryid == 0) { $this->_error(self::ISNOTCOUNTRYID); return false; } $country = Countries::find($context['country_id']); if (!empty($country->code)) { $this->countryCode = $country->code; } else { return false; } if (Countries::isITbyId($countryid)) { if (!is_numeric($value) || strlen($value) != 11) { $this->_error(self::INVALIDVAT); return false; } } elseif (Countries::isUEbyId($countryid)) { return $this->eu_check(); } } return true; }