如果我已经有正则表达式作为c#属性的数据属性,我是否需要stringlength

时间:2018-12-19 22:55:59

标签: c# data-annotations

我在下面有这个。似乎正则表达式就足够了,但不确定吗?

    [Required(ErrorMessage = "Routing is required")]
    [StringLength(9, MinimumLength = 9, ErrorMessage = "Your routing number must be 9 digits")]
    [RegularExpression(@"^\d{9}$", ErrorMessage = "Routing number must be 9 digits. 0-9")]
    public string Routing { get; set; }

0 个答案:

没有答案