I want to create a custom validation attribute, in which I want to compare the value of my property with another property's value in my model class.
For example I have in my model class:
...
public string SourceCity { get; set; }
public string DestinationCity { get; set; }
And I want to create a custom attribute to use it like this:
[Custom("SourceCity", ErrorMessage = "the source and destination should not be equal")]
public string DestinationCity { get; set; }
//this wil lcompare SourceCity with DestinationCity
How can I get there?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…