正则表达式适用于所有filelds.ASP.NET Core

时间:2018-09-25 20:28:33

标签: c# asp.net-core

这是一种非常奇怪的情况,我对密码进行了验证,并且只需要数字和最小一个大写字符。但是此验证也适用于所有领域和电子邮件!在电子邮件上,我还有另一个验证。什么问题?请问我该如何写正确的数字正则表达式和最小一个大写密码,以及为什么我对所有文件都有疑问

 public class ResetPasswordViewModel
    {
        public string Id { get; set; }

        [Required(ErrorMessage = "minimum 5")]
        [RegularExpression(@"(?i)\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b", 
        ErrorMessage = "No format Email")]
        [Display(Name = "Email")]
        public string Email { get; set; }

        [Required(ErrorMessage = "minimum 5")]
        [StringLength(30, MinimumLength = 5, ErrorMessage = "minimum 5")]
        [Display(Name = "Password")]
        [RegularExpression("(?=.*[a-zA-Z0-9])$", ErrorMessage = "minimum one 
        Uppercase and numbers")]
        [DataType(DataType.Password)]
        public string Password { get; set; }



        [Required]
        [Compare("Password", ErrorMessage = "Not compare")]
        [DataType(DataType.Password)]
        [Display(Name = "Password Confirm")]
        public string ConfirmPassword { get; set; }

        public string Code { get; set; }
    }

当我将其引入密码时,此验证开始于电子邮件。为什么?

[RegularExpression("(?=.*[a-zA-Z0-9])$", ErrorMessage = "minimum one 
        Uppercase and numbers")]

0 个答案:

没有答案