@fnzc/nz-bank-account-validator

中文文档
1.0.3发布于 2019/08/31MITTypeScriptCommonJS近 30 天下载 5732

Validates New Zealand bank accounts

原始使用文档
文档目录7 节
  1. Installation
  2. Usage
  3. Algorithm
  4. Bank account number validation
  5. Changelog
  6. Contributing
  7. License

nz-bank-account-validator

npm

A validator for New Zealand bank accounts

Installation

npm install --save @fnzc/nz-bank-account-validator

or

yarn add @fnzc/nz-bank-account-validator

Usage

Function requires four string parameters:

  • Bank ID
  • Bank Branch
  • Account Base
  • Suffix Returns a boolean.
var bankAccountValidator = require('@fnzc/nz-bank-account-validator');
bankAccountValidator.isValidNZBankNumber('00', '0000', '00000000', '000');

Algorithm

The algorithm is based on the 'Non-Resident Withholding Tax And Resident Withholding Tax Specification Document' issues by the Inland Revenue on the 31st of March 2016.

Bank account number validation

The bank account number format used by all banks is numeric and includes the following parts:

  • Bank ID (maximum 2 digits)
  • Bank branch (maximum 4 digits)
  • Account base number (maximum 8 digits)
  • Account suffix (maximum 4 digits).

For processing at Inland Revenue the fields for the individual account number parts are all of maximum size. If less than the maximum number of digits is supplied, then values are right justified and the fields padded with zeroes (where applicable).

The first step in the validation process is to verify the bank branch number. For every bank ID, a range of branch numbers is allocated. If the bank ID is not one of those listed below or the branch number is not included in the range(s) specified, the bank account number is invalid. If the branch number is valid, then derive the appropriate code from the “Algorithm” column below and perform the second validation step as outlined in the first paragraph over the page.

Bank IDValid Branch NumbersAlgorithm
010001 - 0999, 1100 - 1199, 1800 - 1899See note
020001 - 0999, 1200 - 1299See note
030001 - 0999, 1300 - 1399, 1500 - 1599, 1700 – 1799 , 1900 - 1999See note
042020 - 2024
060001 - 0999, 1400 - 1499See note
086500 - 6599D
090000E
105165 - 5169See note
115000 - 6499, 6600 - 8999See note
123000 - 3299, 3400 – 3499, 3600 - 3699See note
134900 - 4999See note
144700 - 4799See note
153900 - 3999See note
164400 - 4499See note
173300 - 3399See note
183500 - 3599See note
194600 - 4649See note
204100 - 4199See note
214800 - 4899See note
224000 - 4049See note
233700 - 3799See note
244300 - 4349See note
252500 - 2599F
262600 - 2699G
273800 - 3849See note
282100 - 2149G
292150 - 2299G
302900 - 2949See note
312800 - 2849X
336700 - 6799F
352400 - 2499See note
389000 - 9499See note
888800 - 8805

Note: If the account base number is below 00990000 then apply algorithm A, otherwise apply algorithm B.

The second validation step is a modulus n algorithm applied to the whole account number. The algorithm type is derived from the table on the previous page. Follow this process:

  • Identify the corresponding weight factor for every digit in the account number as showninthetablebelow. Note:allfields(iebankID,bankbranch,accountbase and account suffix) are right justified and padded with zeroes.
  • Add together the products of the weight factors and their associated account number digit. If the algorithm E or G is used then add the two digits of the product (tens and ones), and again the two digits of the result before summing (see example 3 on page 16).
  • Divide the sum by the value in the “Modulo” column below. If the remainder is zero then the bank account number is valid.
AlgorithmBankBranchAccount BaseSuffixModulo
A00637900A58421000011
B00000000A58421000011
C37000091A53421000011
D00000007654321000011
E00000000005432000111
F00000001731731000010
G00000001371371037110
X0000000000000000001

Note 1: Algorithm C is not currently used by the banks. Note 2: Algorithm X (for Bank ID 31) always verifies the bank account number to be valid. It is included in this table so the same validation logic can be applied to all account numbers.

Changelog

Contributing

Pull requests are welcome.

License

版本与发布记录

@fnzc/nz-bank-account-validator 共发布 3 个版本,首次发布于 2019/01/30;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.3latest2019/08/317 年前
1.0.22019/01/307 年前
1.0.12019/01/307 年前

关于 @fnzc/nz-bank-account-validator 的常见问题

@fnzc/nz-bank-account-validator 是什么?

Validates New Zealand bank accounts

如何安装 @fnzc/nz-bank-account-validator?

在项目目录运行 npm install @fnzc/nz-bank-account-validator,或使用 pnpm add / yarn add / bun add。

@fnzc/nz-bank-account-validator 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fnzc/nz-bank-account-validator 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@fnzc/nz-bank-account-validator 可以商用吗?

@fnzc/nz-bank-account-validator 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fnzc/nz-bank-account-validator 的下载量有多少?

根据 npm 官方下载统计,@fnzc/nz-bank-account-validator 在 2026/10/15 – 2026/11/13 这 30 天内被下载 5,732 次,日均约 191 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fnzc/nz-bank-account-validator 还在维护吗?

最新版本 1.0.3 发布于 2019/08/31(7 年前);至今共发布 3 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/01/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。