I have a class "SampleDTO.cs" and i would like assign data annanatoation attributes during run time.
For an example
SampleDTO.cs {
public string Name
{
get;set;
}
}
I need to force, required field validation, minimum or maximum field validation based on condition. I have been searching for a forum and couldnt get any solution..
My expection is,
if(some condition1)
{
check SampleDTO.Name property for Required field validator check.
}
else if(some condition2)
{
check SampleDTO.Name property for minimum and maximum length check.
}
else{
someother check.
}
(This can be done easily, by decorating the required, min/max length attribute on the SampleDTO.cs class. I am expecting this to implement it dynamically instead of static assignment.)
Thanks in advance.