Slagmoth
Slagmoth
CC#
Created by Slagmoth on 5/1/2023 in #help
Custom attribute for ValidationAttribute, am I able to get the property being validated dynamically?
Looking for a way to have a custom validation attribute apply to two related properties... simple solution is that I just make a reversed validation for the related property but would like it cleaner if possible. So I have two dropdowns in a grid that are interdependent... so if one says "Direct" the other can't have a value of "A". Both are validated off the same stuff all I would like to be able to do is just pass which one is being validated to the attribute. So is it possible to get which property is being called dynamically from either object value or ValidationContext validationContext in the parameters or through reflection?
9 replies