DragonBe\Vies\Validator\ValidatorNL::validate PHP Method

validate() public method

public validate ( string $vatNumber ) : boolean
$vatNumber string
return boolean
    public function validate($vatNumber)
    {
        if (strlen($vatNumber) != 12) {
            return false;
        }
        if (strtoupper($vatNumber[9]) != 'B') {
            return false;
        }
        if ((int) substr($vatNumber, -2) == 0) {
            return false;
        }
        $checksum = (int) $vatNumber[8];
        $weights = array(9, 8, 7, 6, 5, 4, 3, 2);
        $checkval = $this->sumWeights($weights, $vatNumber);
        $checkval = $checkval % 11 > 9 ? 0 : $checkval % 11;
        if ($checkval != $checksum) {
            return false;
        }
        return true;
    }
ValidatorNL