ua-tax-number
v1.0.1
Published
Ukrainian Tax Number validation
Maintainers
Readme
ua-tax-number
Ukrainian Tax Number validation library
Methods to use
isValidIPN(ipn)validates the tax number and returnstrueorfalsevalidateIPN(ipn)validates the tax number and returns the object with thevalidproperty oftrue/falseanderrormessage in case of invalid numbergetDataFromIPNin addition to validation result also returns the date of birth and gender based on the number provided (but only for the valid number)
Example of usage
const { isValidIPN, validateIPN, getDataFromIPN } = require('ua-tax-number');
// Example usage
const ipn = '3272518079'; // Replace with the actual IPN to validate
if (isValidIPN(ipn)) {
console.log('Valid IPN:', ipn);
const data = getDataFromIPN(ipn);
console.log('IPN Data:', data);
}
// The above will output:
// Valid IPN: 3272518079
// IPN Data: {
// valid: true,
// data: {
// ipn: '3272518079',
// dateOfBirth: { year: 1989, month: 8, day: 7 },
// gender: 'male',
// serial: '180'
// }
// }
// Validate IPN
const validationResult = validateIPN(ipn);
if (validationResult.valid) {
console.log('IPN is valid');
}
// The above will output:
// IPN is valid (for 3272518079)
// Example of invalid IPN
const invalidIpn = '123456789'; // Invalid IPN (not 10 digits)
if (!isValidIPN(invalidIpn)) {
console.error('Invalid IPN:', invalidIpn);
}
// The above will output:
// Invalid IPN: 123456789Test Coverage
- Current test coverage is 80%+ for statements
| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | |-----------------|---------|----------|---------|---------|-----------------------------| | All files | 84.94 | 46.66 | 100 | 84.94 | | | src | 85.07 | 50 | 100 | 85.07 | | | validation.ts | 85.07 | 50 | 100 | 85.07 | 6-7,19-20,28-29,34-35,46-47 | | src/utils | 84.61 | 33.33 | 100 | 84.61 | | | date.ts | 84.61 | 33.33 | 100 | 84.61 | 5-6,12-13 |
Test Suites: 1 passed, 1 total
Tests: 2 passed, 2 total
