Created
June 22, 2011 15:33
-
-
Save waldyrfelix/1040352 to your computer and use it in GitHub Desktop.
Exemplo de StringLength e RegularExpression aplicado
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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