Property Matching With Data Annotations

added by daniewat82
1/9/2010 1:51:46 PM

1 Kicks, 150 Views

I wondered if it would be possible to compare two properties using data annotations. Usually you place the data annotations attribute on a property to validate the data in some way. I quickly knocked up a custom ValdationAttribute that could be placed on a class that checks for equality between two properties of the class. It checks both type and value equality.