Skip to content

FluentValidation library used in projects created by the Code Generator tool.

License

Notifications You must be signed in to change notification settings

Tolitech/CodeGenerator.FluentValidation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Tolitech.CodeGenerator.FluentValidation

FluentValidation library used in projects created by the Code Generator tool.

This project contains basic validations used frequently, such as CPF and CNPJ validation through the FluentValidation library.

Tolitech Code Generator Tool: http://www.tolitech.com.br

Examples:

public class Person
{
    public Person(string name, string document)
    {
        Name = name;
        Document = document;
    }

    public string Name { get; private set; }

    public string Document { get; private set; }
}
public class PersonValidator : AbstractValidator<Person>
{
    public PersonValidator()
    {
        RuleFor(x => x.Document)
            .IsValidCPF();
    }
}
var person = new Person("Name", "999.888.777-14");
var validator = new PersonValidator();
var result = validator.Validate(person); // result.IsValid == true
var person = new Person("Name", "99988877714");
var validator = new PersonValidator();
var result = validator.Validate(person); // result.IsValid == true
RuleFor(x => x.Document)
    .IsValidCPF();
RuleFor(x => x.Document)
    .IsValidCNPJ();
RuleFor(x => x.Document)
    .IsValidCPFOrCNPJ();

About

FluentValidation library used in projects created by the Code Generator tool.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages