Zum Hauptinhalt springen

VatValidatorEUService

This class validates vat numbers by using the EU service (http://ec.europa.eu).

context.enableModules();
const { VatValidatorEUService } = require("ou.sp.validation.VatValidatorEUService");

const isValid = VatValidatorEUService.isValid("de-306219982");

try {
const isValid = VatValidatorEUService.validate("de-306219982");
} catch (error) {
util.log(error.message);
}

Constructors​

Constructor​

new VatValidatorEUService(): VatValidatorEUService

Returns​

VatValidatorEUService

Methods​

isValid()​

static isValid(vat): boolean

Validates a VAT by using the http://ec.europa.eu API.

Warning: This function will not throw an error. If an error occurs, this function will always return false

const isValid = VatValidatorEUService.isValid("de-306219982", true);
// isValid = true

Parameters​

vat​

string

an unformatted vat string

Returns​

boolean

true if valid, otherwise false


validate()​

static validate(vat): boolean

Validates a VAT by using the http://ec.europa.eu API.

Warning: This function will throws error.

const isValid = VatValidatorEUService.isValid("de-306219982", true);
// isValid = true

Parameters​

vat​

string

an unformatted vat string

Returns​

boolean

true if valid, otherwise false

Throws​

an error in case of any error