typestack / class-validator

Decorator-based property validation for classes.
MIT License
10.74k stars 777 forks source link

feature: add `@IsVatId()` decorator #2441

Open TigerC10 opened 4 months ago

TigerC10 commented 4 months ago

Description

Add an @IsVatId() Decorator for countries that use VAT.

Proposed solution

ValidatorJS has an isVAT(str, countryCode) function, where countryCode is one of ['AL', 'AR', 'AT', 'AU', 'BE', 'BG', 'BO', 'BR', 'BY', 'CA', 'CH', 'CL', 'CO', 'CR', 'CY', 'CZ', 'DE', 'DK', 'DO', 'EC', 'EE', 'EL', 'ES', 'FI', 'FR', 'GB', 'GT', 'HN', 'HR', 'HU', 'ID', 'IE', 'IL', 'IN', 'IS', 'IT', 'KZ', 'LT', 'LU', 'LV', 'MK', 'MT', 'MX', 'NG', 'NI', 'NL', 'NO', 'NZ', 'PA', 'PE', 'PH', 'PL', 'PT', 'PY', 'RO', 'RS', 'RU', 'SA', 'SE', 'SI', 'SK', 'SM', 'SV', 'TR', 'UA', 'UY', 'UZ', 'VE'].

Should be a fairly straight forward addition.

andrea809 commented 2 months ago

it would be very useful