Socket
Socket
Sign inDemoInstall

au-bn-validator

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.1.0

27

lib/au-bn-validator.js

@@ -23,3 +23,3 @@ "use strict";

return rem === 0;
return abnSum > 0 && rem === 0;
};

@@ -31,2 +31,25 @@

exports.validateTFN = function (tfn) {
var weights = [1, 4, 3, 7, 5, 8, 6, 9, 10];
var modulus = 11;
if (typeof tfn === 'string') {
tfn = tfn.replace(/\s/g, '').replace(/-/g, '').split('');
}
if (tfn.length !== 9) {
return false;
}
var tfnSum = weights.map(function (val, index) {
return val * tfn[index];
}).reduce(function (p, w) {
return p + w;
}, 0);
var rem = tfnSum % modulus;
return tfnSum > 0 && rem === 0;
};
function validateACNorARBN(acn) {

@@ -52,3 +75,3 @@ var weights = [8, 7, 6, 5, 4, 3, 2, 1];

return rem === parseInt(acn[8]);
return acnSum > 0 && rem === parseInt(acn[8]);
}

4

package.json
{
"name": "au-bn-validator",
"version": "1.0.1",
"description": "Validates Australian Business Number (ABN), Australian Company Number (ACN) & Australian Registered Body Number (ARBN)",
"version": "1.1.0",
"description": "Validates Australian Business Number (ABN), Australian Company Number (ACN), Australian Tax File Number (TFN) & Australian Registered Body Number (ARBN)",
"main": "lib/au-bn-validator.js",

@@ -6,0 +6,0 @@ "scripts": {

au-bn-validator
===============
A small npm package that validates Australian Business Number (ABN), Australian Company Number (ACN) & Australian Registered Body Number (ARBN).
A small npm package that validates Australian Business Number (ABN), Australian Company Number (ACN), Australian Tax File Number (TFN) & Australian Registered Body Number (ARBN).

@@ -18,2 +18,4 @@ ## Installation

The module exposes four functions `validateABN`, `validateACN`, `validateTFN` & `validateARBN` to validate ABN, ACN, TFN & ARBN. It will return true if a number is valid otherwise false.
var validator = require('au-bn-validator');

@@ -24,3 +26,9 @@

console.log(validator.validateACN('010 499 966')); // true
console.log(validator.validateTFN('876 543 210')); // true
console.log(validator.validateTFN('876543210')); // true
console.log(validator.validateARBN('00 00')); // false
## Tests
`npm test`

@@ -27,0 +35,0 @@

@@ -46,3 +46,3 @@ "use strict";

var acns = ['', '0', '000 000 001'];
var acns = ['', '0', '000 000 000'];

@@ -55,2 +55,26 @@ acns.forEach(function (acn) {

});
describe('TFN Validator', function () {
it('should return true for valid TFNs', function () {
var abns = ['876 543 210', '876543210'];
abns.forEach(function (abn) {
assert.equal(validator.validateTFN(abn), true);
});
});
it('should return false for invalid TFNs', function () {
var abns = ['', '0', '000 000 000'];
abns.forEach(function (abn) {
assert.equal(validator.validateTFN(abn), false);
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc