Say I have a model which has a payment date
public class PaymentModel
{
[PaymentDateValid]
public DateTime PaymentDate { get; set; }
}
I have created a custom validator PaymentDateValid deriving from ValidationAttribute. The validator needs to lookup from the database the latest payment date and verify that the submitted payment date is after the latest payment date.
Assume that there is some sort of Repository or Service that is used to get the latest payment date and that these are available from a container. Client side validation isn't necessary, but would be a nice to have.
What is the best way to inject these dynamic validation parameters into the validator? Or is there a better way to perform a data driven validation?