Validation of Guid

前端 未结 8 907
忘了有多久
忘了有多久 2020-12-31 02:47

I have a strongly-typed view which has a DropDownListFor attribute on it.

Each item in the dropdown list is represented by a GUID.

What I\'m after is a way

8条回答
  •  南方客
    南方客 (楼主)
    2020-12-31 03:24

    Regex actually does work (if you use the right one!)

    [Required]
    [RegularExpression("^((?!00000000-0000-0000-0000-000000000000).)*$", ErrorMessage = "Cannot use default Guid")]
    public Guid Id { get; set; }
    

提交回复
热议问题