Skip to content

Instantly share code, notes, and snippets.

@TBertuzzi
Last active November 3, 2020 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TBertuzzi/87d71ab48736d918f38a2ce6c8211edd to your computer and use it in GitHub Desktop.
Save TBertuzzi/87d71ab48736d918f38a2ce6c8211edd to your computer and use it in GitHub Desktop.
FluentValidation
using System;
using FluentValidation;
namespace XamarinFluentValidation.Models.Validators
{
public class PessoaValidator : AbstractValidator<Pessoa>
{
public PessoaValidator()
{
RuleFor(x => x.Nome).NotEmpty().WithMessage("Nome Obrigatório").
MaximumLength(30).WithMessage("O Nome pode ter no maximo 30 caracteres");
RuleFor(x => x.Email).NotEmpty().WithMessage("E-mail Obrigatório").
EmailAddress().WithMessage("E-mail Invalido");
RuleFor(x => x.Estado).NotEmpty().WithMessage("Estado Obrigatório");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment