is-valid-acn
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -12,6 +12,6 @@ "use strict"; | ||
return false; | ||
} // strip anything other than digits | ||
} // strip non-alphanumeric characters | ||
var acn = rawAcn.toString().replace(/[^0-9]/g, ''); // check length is 9 digits | ||
var acn = rawAcn.toString().replace(/[^a-zA-Z\d]/gi, ''); // check length is 9 digits | ||
@@ -18,0 +18,0 @@ if (acn.length === 9) { |
{ | ||
"name": "is-valid-acn", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Check if a number is a valid Australian Company Number (ACN)", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -0,3 +1,5 @@ | ||
[![npm](https://img.shields.io/npm/v/is-valid-acn.svg)](https://www.npmjs.com/package/is-valid-acn) ![downloads](https://img.shields.io/npm/dt/is-valid-acn.svg) [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest) | ||
# is-valid-acn | ||
Check if a number is a valid Australian Company Number (ACN) | ||
Check if a number is a valid Australian Company Number (ACN). | ||
@@ -9,6 +11,2 @@ ## tl;dr | ||
## Accepted formats | ||
* Strings with one or multiple class names: `a`, `a b` | ||
* Array of strings with one or multiple class names: `['a', 'b']`, `['a b', 'c d']`. | ||
## Examples | ||
@@ -22,2 +20,5 @@ | ||
< true | ||
> isValidACN('010-499-966'); | ||
< true | ||
``` | ||
@@ -24,0 +25,0 @@ |
@@ -8,4 +8,4 @@ const weights = [8, 7, 6, 5, 4, 3, 2, 1]; | ||
// strip anything other than digits | ||
const acn = rawAcn.toString().replace(/[^0-9]/g, ''); | ||
// strip non-alphanumeric characters | ||
const acn = rawAcn.toString().replace(/[^a-zA-Z\d]/gi, ''); | ||
@@ -12,0 +12,0 @@ // check length is 9 digits |
@@ -10,2 +10,14 @@ import isValidACN from './index'; | ||
it('returns false for non-numeric input', () => { | ||
const result = isValidACN('elephants'); | ||
expect(result).toBe(false); | ||
}); | ||
it('returns false for partially numeric input', () => { | ||
const result = isValidACN('010499966fox'); | ||
expect(result).toBe(false); | ||
}); | ||
it('returns false for invalid input with invalid length', () => { | ||
@@ -22,3 +34,8 @@ const result = isValidACN('123'); | ||
}); | ||
it('returns true for valid numeric input', () => { | ||
const result = isValidACN(143526096); | ||
expect(result).toBe(true); | ||
}); | ||
it('returns true for valid input', () => { | ||
@@ -35,2 +52,8 @@ const result = isValidACN('010499966'); | ||
}); | ||
it('returns true for valid input with dashes', () => { | ||
const result = isValidACN('010-499-966'); | ||
expect(result).toBe(true); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5772
83
42