Mercurial > altnet-hispano
diff Agendas/trunk/src/Agendas.Web/Models/PersonaModel.cs @ 259:e6c041d8e1bf
Ticket #193.1: Al guardar (nuevo/modificar) una persona, que la cuenta de twitter no comience con @
author | juanjose.montesdeocaarbos |
---|---|
date | Thu, 20 Oct 2011 08:16:55 -0300 |
parents | 730b80afa70d |
children | 8a2a58b5e2d6 |
line wrap: on
line diff
--- a/Agendas/trunk/src/Agendas.Web/Models/PersonaModel.cs Wed Oct 19 22:59:02 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web/Models/PersonaModel.cs Thu Oct 20 08:16:55 2011 -0300 @@ -1,7 +1,10 @@ using System; using System.Collections.Generic; +//using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations; using System.Web.Mvc; +using DataAnnotationsExtensions; + namespace AltNetHispano.Agendas.Web.Models { @@ -15,12 +18,14 @@ public string Nombre { get; set; } [Required] + [CustomValidation(typeof(PersonaValidation), "IsTwitterAccount")] public string Twitter { get; set; } [Required] + [Email] public string EMail { get; set; } - [DataType(DataType.Url)] + [Url] public string Blog { get; set; } public string[] Roles { get; set; } @@ -36,12 +41,14 @@ public string Nombre { get; set; } [Required] + [CustomValidation(typeof(PersonaValidation), "IsTwitterAccount")] public string Twitter { get; set; } [Required] + [Email] public string EMail { get; set; } - [DataType(DataType.Url)] + [Url] public string Blog { get; set; } public string[] Roles { get; set; } @@ -70,4 +77,17 @@ [HiddenInput] public string Blog { get; set; } } + + //TODO: Ver donde movemos esta clase. + public class PersonaValidation + { + public static ValidationResult IsTwitterAccount(string value) + { + //[RegularExpression(@"^([\w\d\-\.]+)$")] + return value.StartsWith("@") + ? new ValidationResult("No debe ingresar el arroba al escribir la cuenta de twitter.") + : ValidationResult.Success; + } + } + } \ No newline at end of file