GithubHelp home page GithubHelp logo

aueda / maoli Goto Github PK

View Code? Open in Web Editor NEW
11.0 11.0 6.0 1.41 MB

Maoli is a C# helper library for common Brazilian business rules (CEP, CPF, CNPJ, and number speller), compatible with .NET Framework 4.0+, .NET Core 1.0+, and .NET 5+.

License: MIT License

C# 100.00%
cep cnpj cnpj-validation cpf cpf-validation extenso numbers-to-text validation validator

maoli's People

Contributors

aueda avatar gitter-badger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

maoli's Issues

NetCore compatibility

Hi,

I've had some compatibility warnings by using this library on my netcore project.

Is it compatible with netcore project?

Cpf.Validate retorna true, mesmo quando a string tem caracteres a mais

O CPF 58666979046999 (coloquei três 9s a mais, no final), por exemplo, é inválido e mesmo assim a função Cpf.Validate retorna true. Não sei se esse comportamento é intencional, mas achei estranho. Estranhamente, parece que a validação de CEP é a única que considera a quantidade de caracteres.

Exemplo:

using System;
using Maoli;
					
public class Program
{
	public static void Main()
	{
		var cpfs = new[] {
			"58666979046", // válido
			"58666979046999", // inválido?
			"586.669.790-46.999", // inválido?
		};
		
		foreach (string cpf in cpfs)
			Console.WriteLine("CPF {0} é válido? {1}", cpf, Cpf.Validate(cpf) ? "SIM" : "NÃO");
		
		var cnpjs = new[] {
			"12658591000178", // válido
			"12658591000178999", // inválido
			"12.658.591/0001-78.999", // inválido
		};
		
		foreach (string cnpj in cnpjs)
			Console.WriteLine("CNPJ {0} é válido? {1}", cnpj, Cnpj.Validate(cnpj) ? "SIM" : "NÃO");
		
		var ceps = new[] {
			"58088650",
			"580886500",
			"58088-650-99"
		};
		
		foreach (string cep in ceps)
			Console.WriteLine("CEP {0} é válido? {1}", cep, Cep.Validate(cep) ? "SIM" : "NÃO");
	}
}

Resultado:

  • CPF 58666979046 é válido? SIM
  • CPF 58666979046999 é válido? SIM
  • CPF 586.669.790-46.999 é válido? SIM
  • CNPJ 12658591000178 é válido? SIM
  • CNPJ 12658591000178999 é válido? SIM
  • CNPJ 12.658.591/0001-78.999 é válido? SIM
  • CEP 58088650 é válido? SIM
  • CEP 580886500 é válido? NÃO
  • CEP 58088-650-99 é válido? NÃO

No .NET Fiddle: https://dotnetfiddle.net/lZluRC

CPFs with same numbers

CPFs with the same numbers repeated like 00000000000, 11111111111 ... 99999999999 are all been validated by the code, but it is not true.

Check for half-punctuated CPF or CNPJ

Under loose validation mode, check for half-punctuated CPF or CNPJ. A CPF like "999.999.99999" must be invalid. CPF must be considered valid if only has all the punctuation or has only digits. In this case, only "999.999.999-99" or "99999999999" would be valid.

This issue changes how the loose validation mode works.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.