WilvanBil.NationalRegisterNumber
2.0.0
See the version list below for details.
dotnet add package WilvanBil.NationalRegisterNumber --version 2.0.0
NuGet\Install-Package WilvanBil.NationalRegisterNumber -Version 2.0.0
<PackageReference Include="WilvanBil.NationalRegisterNumber" Version="2.0.0" />
paket add WilvanBil.NationalRegisterNumber --version 2.0.0
#r "nuget: WilvanBil.NationalRegisterNumber, 2.0.0"
// Install WilvanBil.NationalRegisterNumber as a Cake Addin #addin nuget:?package=WilvanBil.NationalRegisterNumber&version=2.0.0 // Install WilvanBil.NationalRegisterNumber as a Cake Tool #tool nuget:?package=WilvanBil.NationalRegisterNumber&version=2.0.0
National Register Number
National Register Number is a .NET package for generating and validating Belgian national register numbers. The logic is based on the Official Documentation by the Belgian Government.
Features
- Validation: Verify if a given national register number is valid.
- Generation: Generate valid national register numbers with flexible parameters such as birth date and biological sex.
Installation
Add the package to your project via the .NET CLI:
dotnet add package WilvanBil.NationalRegisterNumber
Alternatively, find it on NuGet Package Manager by searching for WilvanBil.NationalRegisterNumber
.
Usage
After installation, use the static class NationalRegisterNumberGenerator
to generate or validate national register numbers.
Validation
The IsValid
method checks whether a given national register number is valid and returns a boolean (true
/false
).
bool isValid = NationalRegisterNumberGenerator.IsValid("90022742191");
Generation
The Generate
method creates valid national register numbers. The following overloads are available:
string number = NationalRegisterNumberGenerator.Generate();
string number = NationalRegisterNumberGenerator.Generate(DateOnly birthDate);
string number = NationalRegisterNumberGenerator.Generate(BiologicalSex sex);
string number = NationalRegisterNumberGenerator.Generate(DateOnly birthDate, BiologicalSex sex);
string number = NationalRegisterNumberGenerator.Generate(DateOnly minDate, DateOnly maxDate);
string number = NationalRegisterNumberGenerator.Generate(DateOnly minDate, DateOnly maxDate, BiologicalSex sex);
string number = NationalRegisterNumberGenerator.Generate(DateOnly birthDate, int followNumber);
Parameters
followNumber
: A number between1
and998
(inclusive). This parameter helps ensure uniqueness when generating numbers for the same date.minDate
must be greater than or equal to1900/01/01
.
Exceptions
If the input parameters are invalid, the following exceptions may be thrown:
ArgumentException
: Indicates an invalid parameter with an explanatory message.
Example Usage
Validate a National Register Number
bool isValid = NationalRegisterNumberGenerator.IsValid("90022742191");
Console.WriteLine($"Is valid: {isValid}");
Generate a Random National Register Number
string randomNumber = NationalRegisterNumberGenerator.Generate();
Console.WriteLine($"Generated number: {randomNumber}");
Generate with Specific Parameters
string numberByDate = NationalRegisterNumberGenerator.Generate(new DateOnly(1990, 1, 1));
string numberBySex = NationalRegisterNumberGenerator.Generate(BiologicalSex.Male);
string numberByDateAndSex = NationalRegisterNumberGenerator.Generate(new DateOnly(1990, 1, 1), BiologicalSex.Female);
Contributing
We welcome contributions to this package! To get started:
- Fork the repository: WilvanBil/NationalRegisterNumber.
- Clone your fork:
git clone https://github.com/YourUsername/NationalRegisterNumber.git
- Create a new branch for your feature or bug fix:
git checkout -b feature/my-new-feature
- Make your changes and ensure all tests pass.
- Submit a pull request with a clear description of your changes.
Running Tests
Before submitting your changes, run the test suite:
dotnet test
!! WARNING !!
This package is intended for testing and research purposes only. Do not use it in a live or production environment. It is specifically designed for unit and integration testing scenarios.
License
This project is licensed under the MIT License. See the LICENSE
file for more details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net8.0
- No dependencies.
-
net9.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.