Skip to content

Instantly share code, notes, and snippets.

@waldyrfelix
Created June 22, 2011 15:33
Show Gist options
  • Save waldyrfelix/1040352 to your computer and use it in GitHub Desktop.
Save waldyrfelix/1040352 to your computer and use it in GitHub Desktop.
Exemplo de StringLength e RegularExpression aplicado
using System.ComponentModel.DataAnnotations;
namespace AppWeb.ViewModels
{
public class LoginViewModel
{
[Required(ErrorMessage = "Login é um campo obrigatório")]
[StringLength(30, ErrorMessage="O login deve ter no máximo 30 caracteres")]
public string Login { get; set; }
[Required(ErrorMessage = "Senha é um campo obrigatório")]
[StringLength(16, MinimumLength=8, ErrorMessage = "A senha deve ter entre 8 e 16 caracteres")]
[RegularExpression(@"[a-zA-Z0-9]*", ErrorMessage="Na senha somente são permitidos caracteres alfanuméricos")]
public string Senha { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment