Always use current datetime for validation
Some checks failed
continuous-integration/drone/push Build was killed
continuous-integration/drone/pr Build is passing

This commit is contained in:
2025-10-16 18:21:14 +02:00
parent 1226c42f19
commit 62824549fc
2 changed files with 5 additions and 5 deletions

View File

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

View File

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