Using DataAnnotations to compare two model properties

后端 未结 6 855
你的背包
你的背包 2020-12-03 02:23

How would I go about writing a custom ValidationAttribute that compares two fields? This is the common \"enter password\", \"confirm password\" scenario. I need to be sure t

6条回答
  •  隐瞒了意图╮
    2020-12-03 03:13

    You could have a custom validation attribute and apply it on the model and not on individual properties. Here's an example you might take a look at.

提交回复
热议问题