Skip to content
forked from aueda/maoli

Helper library for common brazilian business rules (CPF and CNPJ)

License

Notifications You must be signed in to change notification settings

Brunoalcau/maoli

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#Maoli

Maoli is C# helper library for common brazilian business rules (CEP, CPF and CNPJ), compatible with .NET Framework 4.0 and above.

Currently implements:

  • CEP validation
  • CPF validation
  • CNPJ validation

For client-side validation of CPF and CNPJ, please see Maoli.js.

Documentation

Cep

Cep.Validate(string value) - checks if a string value is a valid CEP representation. Returns true if CEP string is valid; false otherwise.

	if (Cep.Validate("99999-999"))
	{
	  Console.WriteLine("CEP is valid");
	}

Cpf

Cpf.Validate(string value) - checks if a string value is a valid CPF representation. Returns true if CPF string is valid; false otherwise.

	if (Cpf.Validate("999.999.99-99"))
	{
	  Console.WriteLine("CPF is valid");
	}

Cpf.Complete(string value) - completes a partial CPF string by appending a valid checksum trailing. Returns a CPF string with a valid checksum trailing.

	var cpf = Cpf.Complete("99999999")); // outputs "99999999999"

Cnpj

Cnpj.Validate(string value) - checks if a string value is a valid CNPJ representation. Returns true if CNPJ string is valid; false otherwise.

	if (Cnpj.Validate("99.999.999/9999-99"))
	{
	  Console.WriteLine("CPNJ is valid");
	}

Cnpj.Complete(string value) - completes a partial CNPJ string by appending a valid checksum trailing. Returns a CNPJ string with a valid checksum trailing.

	var cnpj = Cnpj.Complete("999999999999")); // outputs "99999999999999"

NuGet Package

To install Maoli using NuGet, run the following command in the Package Manager Console:

Install-Package Maoli

Source Code

Source code is available at GitHub.

License

This project is licensed under the MIT License.

Author

Adriano Ueda @adriueda

About

Helper library for common brazilian business rules (CPF and CNPJ)

Resources

License

Stars

Watchers

Forks

Packages

No packages published