Login
Лапшекодим валидацию, или запрещаем вводить неправильные данные?
2865 просмотров
Перейти к просмотру всей ветки
in Antwort alex445 08.06.22 20:29
А как вы сделаете атрибутную валидацию повтора пароля?
точно также как и всё остальное
public string Password1 {get; set;}
[MustBeEqualValue(nameof(Password1), ErrorMessage="Two passwords must be equal")]
public string Password2 {get; set;}
...
var property = validationContext.ObjectType.GetProperty(_comparisonPropertyName); comparisonValue =(xxx)property.GetValue(validationContext.ObjectInstance) if (currentValue > comparisonValue) return new ValidationResult(ErrorMessage); return ValidationResult.Success;