SAP-BTP-Spielwiese/app1/node_modules/validator/es/lib/isVAT.js
Markus Rettig 775ac7b58c completed step 3 from the tutorial
you must login with an BTP account in order to see the app
2024-02-08 16:13:36 +01:00

16 lines
No EOL
493 B
JavaScript

import assertString from './util/assertString';
export 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}))$/,
IT: /^(IT)?[0-9]{11}$/,
NL: /^(NL)?[0-9]{9}B[0-9]{2}$/
};
export default function isVAT(str, countryCode) {
assertString(str);
assertString(countryCode);
if (countryCode in vatMatchers) {
return vatMatchers[countryCode].test(str);
}
throw new Error("Invalid country code: '".concat(countryCode, "'"));
}