acnabn-validator

1.0.0 • Public • Published

ACN & ABN Validator

Description

This is a small, lightweight module that helps you recognize and validate Australian Business Numbers (ABN) and Australian Company Numbers (ACN).

Installation

Install acnabn-validator as a dependency using npm:

npm install acnabn-validator --save

Usage

Here’s a quick example to get you started:

import { parseAcnAbn } from 'acnabn-validator';

const code = '004085616';
const result = parseAcnAbn(code);

console.log(result); // { type: 'ACN', code: '004085616', valid: true }

API

parseAcnAbn(code)

  • code: string - The ABN or ACN code you want to validate and recognize.

Returns an object containing:

  • type: string | null - The type of code recognized ('ABN' or 'ACN'). Returns null if the code is neither.
  • code: string - The input code.
  • valid: boolean - Whether the recognized code is valid or not.

Example

import { parseAcnAbn } from 'acnabn-validator';

// Validate ACN
let code = '004085616';
let result = parseAcnAbn(code);
console.log(result); // { type: 'ACN', code: '004085616', valid: true }

// Validate ABN
code = '51824753556';
result = parseAcnAbn(code);
console.log(result); // { type: 'ABN', code: '51824753556', valid: true }

Contributing

Contributions are always welcome! Please run the tests before proposing a change.

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i acnabn-validator

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

5.08 kB

Total Files

5

Last publish

Collaborators

  • muchbetter