#Maoli.Mvc
Maoli.Mvc is ASP.NET MVC helper library for common brazilian business rules (CPF, CNPJ and CEP), compatible with .NET Framework 4.0 and above.
Currently implements:
- CPF validation (both client and server-side)
- CNPJ validation (both client and server-side)
For client-side validation of CPF and CNPJ, please see Maoli.js.
For server-side validation of CPF and CNPJ, please see Maoli.
Cep
- this attribute checks if a string value is a valid CEP representation.
public class CepModel
{
[Cep("CEP is invalid")]
public string Cep { get; set; }
}
Cpf
- this attribute checks if a string value is a valid CPF representation.
public class CpfModel
{
[Cpf("CPF is invalid")]
public string Cpf { get; set; }
}
PunctuatedCpf
- this attribute checks if a string value is a valid CPF representation. Using this validation is necessary to include the punctuation.
public class PunctuatedCpfModel
{
[PunctuatedCpf("CPF is invalid or missing punctuation")]
public string Cpf { get; set; }
}
Cnpj
- this attribute checks if a string value is a valid CNPJ representation.
public class CnpjModel
{
[Cnpj("CNPJ is invalid")]
public string Cnpj { get; set; }
}
PunctuatedCnpj
- this attribute checks if a string value is a valid CNPJ representation. Using this validation is necessary to include the punctuation.
public class PunctuatedCnpjModel
{
[PunctuatedCnpj("CNPJ is invalid or missing punctuation")]
public string Cnpj { get; set; }
}
First, include jQuery and jQuery Validation scripts:
<script src="jquery-2.0.3.js"></script>
<script src="jquery.validate.js"></script>
<script src="jquery.validate.unobtrusive.js"></script>
Next, include Maoli scripts:
<script src="jquery-2.0.3.js"></script>
<script src="jquery.validate.js"></script>
<script src="jquery.validate.unobtrusive.js"></script>
<script src="maoli.js"></script>
<script src="jquery.validate.maoli.js"></script>
To install Maoli using NuGet, run the following command in the Package Manager Console:
PM> Install-Package Maoli.Mvc
The NuGet package depends on these packages:
NuGet automatically resolves these dependencies.
Source code is available at GitHub.
This project is licensed under the MIT License.
Adriano Ueda @adriueda