Advertisement
lukealderton

SmartBlogLibraries 2.1.0 comment model

Apr 27th, 2015
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.10 KB | None | 0 0
  1. using System;
  2. using System.ComponentModel.DataAnnotations;
  3. using System.Web;
  4.  
  5. namespace SmartBlogLibraries.Models
  6. {
  7.     /// <summary>
  8.     /// The model to be used when adding a comment form to SmartBlog.
  9.     /// </summary>
  10.     public class SmartBlogCommentFormModel
  11.     {
  12.         /// <summary>
  13.         /// Name of the person who made the comment.
  14.         /// </summary>
  15.         [Required(ErrorMessage = "Name is required")]
  16.         [RegularExpression(@"^((?!Name).)*$", ErrorMessage = "Name is required")]
  17.         [DataType(DataType.Text)]
  18.         [Display(Name = "Name")]
  19.         public String Name { get; set; }
  20.  
  21.         /// <summary>
  22.         /// Email of the person who made the comment.
  23.         /// </summary>
  24.         [Required(ErrorMessage = "Email is required")]
  25.         [RegularExpression(@"^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$", ErrorMessage = "Invalid Email Address")]
  26.         [DataType(DataType.Text)]
  27.         [Display(Name = "Email")]
  28.         public String Email { get; set; }
  29.  
  30.         /// <summary>
  31.         /// Website of the person who made the comment.
  32.         /// </summary>
  33.         [DataType(DataType.Text)]
  34.         [Display(Name = "Website")]
  35.         public String Website { get; set; }
  36.  
  37.         /// <summary>
  38.         /// Comment of the person who made the comment.
  39.         /// </summary>
  40.         [Required(ErrorMessage = "Comment is required")]
  41.         [RegularExpression(@"^(((?!Your Comment).|(Your Comment.).|\n)*)$", ErrorMessage = "Comment is required")]
  42.         [DataType(DataType.MultilineText)]
  43.         [Display(Name = "Comment")]
  44.         public String Comment { get; set; }
  45.  
  46.         /// <summary>
  47.         /// The value that should be correct before the form is posted.
  48.         /// </summary>
  49.         [Required(ErrorMessage = "Security question is required")]
  50.         [RegularExpression(@"^(4)*$", ErrorMessage = "Invalid security answer")]
  51.         [DataType(DataType.Text)]
  52.         [Display(Name = "Security Question")]
  53.         public String SecurityQuestion { get; set; }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement