array( 'country' => t('Belgium'), 'demonym' => t('belgian'), 'validator' => '_is_valid_be_vat', ), 'nl' => array( 'country' => t('Netherlands'), 'demonym' => t('dutch'), 'validator' => '_is_valid_nl_vat', ), ); } /** * BE VAT Validator callback function */ function _is_valid_be_vat($vat = NULL) { $matches = array(); if (!preg_match('/BE(\d{8})(\d{2})/', $vat, $matches)) { return FALSE; } return (97 - ($matches[1] % 97)) == $matches[2]; } /** * NL VAT Validator callback function */ function _is_valid_nl_vat($vat) { $matches = array(); if (!preg_match('/NL(\d{9})B\d{2}/', $vat, $matches)) { return FALSE; } $sum = 0; for ($i = 0; $i < 8; $i++) { $sum += (9 - $i) * $matches[1][$i]; } $sum %= 11; return $sum == $matches[1][8]; }