Use current datetime for validation #17

Merged
thomas.nuyken merged 2 commits from main into production 2025-10-16 18:27:38 +02:00
2 changed files with 5 additions and 5 deletions
Showing only changes of commit 62824549fc - Show all commits

View File

@@ -26,13 +26,13 @@ public static class CreateConsumption
{
public Validator(TimeProvider timeProvider)
{
DateTime todayEndOfDay = timeProvider.GetUtcNow()
Func<DateTimeOffset> getTodayEndOfDay = () => timeProvider.GetUtcNow()
.Date
.AddDays(1)
.AddTicks(-1);
RuleFor(x => x.DateTime.ToUniversalTime())
.LessThanOrEqualTo(todayEndOfDay)
.LessThanOrEqualTo(_ => getTodayEndOfDay())
.WithName(nameof(Request.DateTime));
RuleFor(x => x.Distance)

View File

@@ -26,13 +26,13 @@ public static class UpdateConsumption
{
public Validator(TimeProvider timeProvider)
{
DateTime todayEndOfDay = timeProvider.GetUtcNow()
Func<DateTimeOffset> getTodayEndOfDay = () => timeProvider.GetUtcNow()
.Date
.AddDays(1)
.AddTicks(-1);
RuleFor(x => x.DateTime.ToUniversalTime())
.LessThanOrEqualTo(todayEndOfDay)
.LessThanOrEqualTo(_ => getTodayEndOfDay())
.WithName(nameof(Request.DateTime));
RuleFor(x => x.Distance)