Implementation of common types used for Brazilian identifiers management (validation, formatting etc.)
$ dotnet add package NBrzId.CommonThis library provides basic types for handling Brazilian identifiers, such as CPF and CNPJ, in .NET applications.
This library introduces types specifically designed to handle Brazilian identifiers with ease and reliability in .NET applications. The initial release, v0.1.0, includes the following core components:
IBrzIdentifier: A base interface for identifiers.Cpf: Class to represent CPF identifiers.Cnpj: Class to represent CNPJ identifiers.BrzIdentifier: A static access point providing singleton instances of Cpf and Cnpj.BaseBrzIdentifier: An abstract class with a default implementation for the property FormattingCharacters.Release v1.0.0 included changes to support the new alphanumeric CNPJ format according to "Instrução Normativa RFB nº 2229".
To include this library in your .NET project, add it as a dependency via NuGet:
dotnet add package NBrzId.Common --version 1.0.1
You can start by accessing the pre-build identifier instances directly through the BrzIdentifier static class. Below is an example that demonstrates basic functionality:
using YourLibraryNamespace;
var cpf = BrzIdentifier.Cpf;
Console.WriteLine(cpf.Mask);
You may also create your own identifier classes for any identifier by implementing the IBrzIdentifier interface:
using YourLibraryNamespace;
public class VoterID : IBrzIdentifier
{
public char[] FormattingCharacters => new char[] { '/' };
public int Length => 12;
public string Mask => "NNNNNNNNNN/NN";
public char PaddingCharacter => '0';
}
This library targets .NET Standard 2.0, ensuring compatibility with .NET Core, .NET 5/6/7/8, and .NET Framework 4.6.1+.
This library is in active development. Planned features for future releases include additional Brazilian identifiers (IE, Suframa, PIS) as needed.
Contributions are welcome! Please open an issue to report bugs or discuss improvements.
This project is licensed under the MIT License. See the LICENSE.md file for details.