public function isValid($value, $checkExistence = false)
    {
        if (null === $value || '' === $value) {
            return false;
        }

        $countryCode = substr($value, 0, 2);
        $vatin = substr($value, 2);

        if (false === $this->isValidCountryCode($countryCode)) {
            return false;
        }

        if (0 === preg_match('/^(?:'.$this->patterns[$countryCode].')$/', $vatin)) {
            return false;
        }

        if (true === $checkExistence) {
            $result = $this->getViesClient()->checkVat($countryCode, $vatin);

            return $result->isValid();
        }

        return true;
    }
public function isValid($value, $checkExistence = false)
    {
        if (null === $value || '' === $value) {
            return false;
        }

        $countryCode = substr($value, 0, 2);
        $vatin = substr($value, 2);

        if (false === $this->isValidCountryCode($countryCode)) {
            return false;
        }

        if (0 === preg_match('/^(?:'.$this->patterns[$countryCode].')$/', $vatin)) {
            return false;
        }

        if (true === $checkExistence) {
            $result = $this->getViesClient()->checkVat($countryCode, $vatin);

            return $result->isValid();
        }

        return true;
    }
public function isValid ( $ value , $ checkExistence = false ) { if ( null === $ value || '' === $ value ) { return false ; } $ countryCode = substr ( $ value , 0 , 2 ) ; $ vatin = substr ( $ value , 2 ) ; if ( false === $ this -> isValidCountryCode ( $ countryCode ) ) { return false ; } if ( 0 === preg_match ( '/^(?:' . $ this -> patterns [ $ countryCode ] . ')$/' , $ vatin ) ) { return false ; } if ( true === $ checkExistence ) { $ result = $ this -> getViesClient ( ) -> checkVat ( $ countryCode , $ vatin ) ; return $ result -> isValid ( ) ; } return true ; }
Returns true if value is a valid VAT identification number, false
otherwise

@param string $value          Value
@param bool   $checkExistence In addition to checking the VATIN's format
for validity, also check whether the VATIN
exists. This requires a call to the VIES
web service.

@return bool
Returns true if value is a valid VAT identification number false otherwise