My User model has these data annotations to validate input fields:
[Required(ErrorMessage = \"Username is required\")]
[StringLength(16, ErrorMessage = \"Must be
You can use the compare annotation to compare two values, and if you need to make sure it isn't persisted anywhere downstream (For example if you are using EF) You can also add NotMapped to ignore any entity->DB mapping
For a full list of data annotations available, see here:
https://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations(v=vs.110).aspx
[Required]
[DataType(DataType.Password)]
public string Password { get; set; }
[Required]
[DataType(DataType.Password)]
[Compare("Password")]
[NotMapped]
public string ConfirmPassword { get; set; }