Skip to content

Commit

Permalink
SCJ-244: Limit trial length to 40 days (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
duncan-oxd authored Jul 25, 2024
1 parent 2a79b74 commit 54e2c42
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions app/Controllers/ScBookingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ public async Task<IActionResult> BookingType(ScBookingTypeViewModel model)
);
}

if (model.EstimatedTrialLength > 40)
{
ModelState.AddModelError(
"EstimatedTrialLength",
"Estimated trial length must be between 1 and 40 days."
);
}

if (model.IsHomeRegistry == null)
{
ModelState.AddModelError(
Expand Down
4 changes: 2 additions & 2 deletions app/Services/DataWriterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ SessionUserInfo userInfo
if (
!bookingInfo.EstimatedTrialLength.HasValue
|| bookingInfo.EstimatedTrialLength.Value < 1
|| bookingInfo.EstimatedTrialLength.Value > 99
|| bookingInfo.EstimatedTrialLength.Value > 40
)
{
throw new InvalidOperationException(
"HearingLength must be greater than zero and less than 100"
"HearingLength must be greater than zero and less than 41"
);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Views/ScBooking/BookingType.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

<div>
<input class="mr-2 form-control d-inline-block EstimatedTrialLength" type="number" min="1"
asp-for="EstimatedTrialLength" />
max="40" asp-for="EstimatedTrialLength" />
<span>days</span>

<div class="mt-2">
Expand Down

0 comments on commit 54e2c42

Please sign in to comment.