I use ASP.NET MVC and implement custom validation using custom data attributes / annotations on my models.
Is it possible to access a property in the parent class of an object inside my custom attribute?
public class MyModel
{
[MyCustomValidator]
public string var1 {get; set;}
public string var2 {get; set;}
}
Note. Using asp.net mvc
public class MyCustomValidatorAttribute : ValidationAttribute
{
public bool override IsValid(Object value)
{
}
}
So basically, so that the check checks another property for a specific value. I tried passing the value var2as a parameter MyCustomValidator, but this will not work.
source
share