Здесь вы можете установить два способа проверки один на стороне клиента, а другой является стороне сервера проверки на стороне
сервера приведены ниже
вы можете сравнить выданную дату от текущей даты/времени, а также сравнить дата истечения срока действия с датой выпуска
public class MyClass : IValidatableObject
{
[Required(ErrorMessage="issued date and time cannot be empty")]
//validate:Must be greater than current date
[DataType(DataType.DateTime)]
public DateTime issuedDateTime { get; set; }
[Required(ErrorMessage="expiry date and time cannot be empty")]
//validate:must be greater than issuedDate
[DataType(DataType.DateTime)]
public DateTime expiryDateTime { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
List<ValidationResult> results = new List<ValidationResult>();
if (issuedDateTime < DateTime.Now)
{
results.Add(new ValidationResult("issued date and time must be greater than current time", new []{"issuedDateTime"}));
}
if (expiryDateTime <= issuedDateTime)
{
results.Add(new ValidationResult("expiryDateTime must be greater that issuedDateTime", new [] {"expiryDateTime"}));
}
return results;
}
}
Я надеюсь, что это вам поможет.