With Validation Application block, there's the following functionality:
I plan to use the DataAnnotations to replace the Validation application block. Are the above possible with DataAnnotations? If so, how'd I implement them?
Any help is appreciated
yes they are possible.
Creating a very simple custom attribute;
public class IsApplicantOldEnoughAttribute : ValidationAttribute
{
public override bool IsValid(object value)
{
if (value == null) return false;
DateTime enteredDate;
try
{
enteredDate = (DateTime)value;
}
catch
{
return false;
}
if ((DateTime.Today.Year - enteredDate.Year) >= 14)
return true;
else
return false;
}
}
Reading from a config file is the same as any code that reads from a config file.
Unsure what you mean by self validation though. Could you please fill me in and I'll try to give an example.