-
Notifications
You must be signed in to change notification settings - Fork 4
DateOffset
Michal Altair Valášek edited this page May 28, 2024
·
2 revisions
Validates if given DateTime falls within defined offset from current date. Useful for validating birthdates etc.
[DateOffset(-120, 0)] // date must be between 120 years ago and DateTime.Today
[DateOffset(null, "30.00.00.00")] // date must be between DateTime.Now and DateTime.Now + 30 daysBy default, the attribute ignores time of day when comparing. If you want to take it in account, set CompareTime to true and modify error message formatting to show the time of day as well.