aueda / maoli.mvc

Maoli.Mvc is ASP.NET MVC helper library for common brazilian business rules (CPF and CNPJ)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

#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.

Documentation

Cep

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

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

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; }
    }

Client-side Validation

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>

NuGet Package

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

PM> Install-Package Maoli.Mvc

NuGet Dependencies

The NuGet package depends on these packages:

NuGet automatically resolves these dependencies.

Source Code

Source code is available at GitHub.

License

This project is licensed under the MIT License.

Author

Adriano Ueda @adriueda

About

Maoli.Mvc is ASP.NET MVC helper library for common brazilian business rules (CPF and CNPJ)

License:MIT License


Languages

Language:C# 80.3%Language:JavaScript 19.5%Language:Shell 0.2%