Created
August 1, 2019 15:29
-
-
Save dannylloyd/add19fc0a0eb29e684dde5a7e2671329 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private bool DateWithinSqlParameters(Event model, DateTime? date, PropertyValidatorContext context) | |
{ | |
var maxDate = DateTime.Today.AddYears(30); | |
context.Rule.MessageBuilder = c=> $"Invalid date entered for {context.PropertyDescription}. Must be between 1/1/2000 - {maxDate.ToString("M/d/yyyy")}"; | |
return !date.HasValue || (date.Value >= new DateTime(2000,1,1) && date.Value <= maxDate); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment