npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

abnacn-validator

v0.0.5

Published

Validates Australian Business Numbers (ABNs) or Australian Company Numbers (ACNs) or a combination of both.

Downloads

1,394

Readme

#abnacn-validator

Validates Australian Business Numbers (ABNs) or Australian Company Numbers (ACNs) or a combination of both.

##Installation Install from npm, like so:

npm install abnacn-validator --save

##Usage The modules exposes three different functions: isValidABN, isValidACN and isValidABNorACN. The latter will return true if the number is either a valid ABN or a valid ACN.

###Importing in ES6 syntax:

// Just import the functions you need.  There's no default export.
import {isValidABN, isValidACN, isValidABNorACN} from "abnacn-validator";

isValidABN("53 004 085 616"); // -> true
isValidABN("0"); // -> false
isValidACN("005 749 986"); // -> true
isValidACN("53 004 085 616"); // -> false  (that's an ABN!)
isValidABNorACN("53 004 085 616"); // -> true
isValidABNorACN("005 749 986"); // -> true
isValidABNorACN("0"); // -> false

###Requiring in CommonJS (Node) syntax:

var abnAcnValidatorObj = require("abnacn-validator");

abnAcnValidatorObj.isValidABN("53 004 085 616"); // -> true
abnAcnValidatorObj.isValidABN("0"); // -> false
abnAcnValidatorObj.isValidACN("005 749 986"); // -> true
abnAcnValidatorObj.isValidACN("53 004 085 616"); // -> false  (that's an ABN!)
abnAcnValidatorObj.isValidABNorACN("53 004 085 616"); // -> true
abnAcnValidatorObj.isValidABNorACN("005 749 986"); // -> true
abnAcnValidatorObj.isValidABNorACN("0"); // -> false

###AMD/RequireJS Syntax For the masochists among you... ;-)

I built this as a UMD module, using Babel's babel-plugin-transform-es2015-modules-umd plugin. So in theory, it should work with the AMD/RequireJS syntax too. But this is untested, so suck it and see.

###Script tag And finally, the humble script tag:

<script src="abnacn-validator.js"></script>

##Development As usual, after cloning the repository, install the required packages like so:

cd abnacn-validator
npm install

Edit the one source file in the /src folder, then run:

npm run build

to build it to the dist folder. Babel will transform from ES6 to CommonJS format, and will also export in UMD format, courtesy of its babel-plugin-transform-es2015-modules-umd plugin.

To run the test suite.

npm test

Increased number of test cases for version 0.0.5. Each valid and invalid ABN was verified at http://www.clearwater.com.au/code before being included in the test cases. Test now also prints each ABN and ACN invidually, so you can see which ones are valid and which are not. Test cases now include varations with and without spaces.

##Acknowlegements As of version 0.0.5, the ABN validation code is taken from Truffala's formula at: http://stackoverflow.com/questions/14174738/regex-to-match-australian-business-number-abn

His code was adapated from the PHP code at http://www.clearwater.com.au/code.

This replaces previous bugged code that was validating invalid ABNs.

ACN validation code taken from Worldspawn's post on this Whirlpool forum thread.