mirror of
https://github.com/Expand-sys/ccashfrontend
synced 2025-12-19 16:12:14 +11:00
27 lines
No EOL
737 B
JavaScript
27 lines
No EOL
737 B
JavaScript
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = isVAT;
|
|
exports.vatMatchers = void 0;
|
|
|
|
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
var vatMatchers = {
|
|
GB: /^GB((\d{3} \d{4} ([0-8][0-9]|9[0-6]))|(\d{9} \d{3})|(((GD[0-4])|(HA[5-9]))[0-9]{2}))$/
|
|
};
|
|
exports.vatMatchers = vatMatchers;
|
|
|
|
function isVAT(str, countryCode) {
|
|
(0, _assertString.default)(str);
|
|
(0, _assertString.default)(countryCode);
|
|
|
|
if (countryCode in vatMatchers) {
|
|
return vatMatchers[countryCode].test(str);
|
|
}
|
|
|
|
throw new Error("Invalid country code: '".concat(countryCode, "'"));
|
|
} |