Spectrum.Ird
2.1.0
See the version list below for details.
dotnet add package Spectrum.Ird --version 2.1.0
NuGet\Install-Package Spectrum.Ird -Version 2.1.0
<PackageReference Include="Spectrum.Ird" Version="2.1.0" />
paket add Spectrum.Ird --version 2.1.0
#r "nuget: Spectrum.Ird, 2.1.0"
// Install Spectrum.Ird as a Cake Addin #addin nuget:?package=Spectrum.Ird&version=2.1.0 // Install Spectrum.Ird as a Cake Tool #tool nuget:?package=Spectrum.Ird&version=2.1.0
New Zealand IRD Number and Bank Account Validation
A library to validate IRD numbers and bank account numbers according to the "Resident Withholding Tax (RWT) and Non-Resident Withholding Tax (NRWT)" specification published by the New Zealand Inland Revenue Department (IRD).
The specification used in this implementation is here.
Installation
This library is distributed with Nuget. The package can be installed by:
Install-Package Spectrum.Ird
Usage
Import the namespace.
using Spectrum.Ird;
IRD Number
Validation
Create an instance of the IRDNumber
with an IRD Number expressed as a long
data type. Call the IsValid()
method to validate it.
var irdNumber = new IrdNumber(49091850);
var result = irdNumber.IsValid();
Static Validation
A static method of validation is available.
var isValid = IrdNumber.IsValid(49091850);
Bank Account
Validation
Create an instance of the NZBankAccount
with a bank account number in its constituent parts. That is, its bank, branch, account base and suffix. Call the IsValid()
method to validate it.
var bank = 1;
var branch = 902;
var accountBase = 68389;
var suffix = 0;
var account = new NZBankAccount(bank, branch, accountBase, suffix);
var isValid = account.IsValid();
Parsing
An instance can also be created by parsing a string
value in the format XX-XXXX-XXXXXXX-XX(X)
where X
is a digit and the suffix can be either 2 or 3 digits. Hyphens, spaces or periods can be used as separators. If the value cannot be parsed, null
is returned.
Parsing an account number does not validate it. Once an instance has been created, it can then be validated.
var account = NZBankAccount.Parse("01-0902-0068389-00");
var isValid = account?.IsValid() ?? false;
A TryParse()
method is also available:
if (NZBankAccount.TryParse("01-0902-0068389-00", out NZBankAccount account))
{
var isValid = account.IsValid();
}
Friendly Display
After an account number has been instantiated, the ToString()
method can be called to get a friendly display of the account number, hyphen separated.
// arrange
var account = new NZBankAccount(1, 902, 68389, 0);
// act
var result = account.ToString();
// assert
Assert.AreEqual("01-0902-0068389-00", result);
Static Validation
A static method of validation is available.
var isValid = NZBankAccount.IsValid(bank, branch, accountBase, suffix);
Acknowledgements
- https://github.com/msdkool/IrdValidator
- https://github.com/wytlytningNZ/NZ-Bank-Account-Validator#readme
Release Notes
2.1.0
2020-09-26
- Added IRD Number validation.
- Refactored
NZBankAccount
to use integer arrays. - Removed
Algorithm
andModulus
as these were never populated.
2.0.0
2020-09-21
- Changed the namespace from
Spectrum.IrdValidation
toSpectrum.Ird
. - Renamed
NZBankAccountValidator
toNZBankAccount
. - Removed AccountNumber property as it is misleading and could be confused with ToString(). This is used privately as part of the validation algorithm.
- Added Parse() to accept bank account numbers in a "XX-XXXX-XXXXXXX-XX(X)" format.
1.0.2
2020-09-17
- Override ToString() to output a human-friendly formatted account number.
1.0.1
2020-09-12
- Added XML documentation.
1.0.0
2020-09-06
- Initial release
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.