Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 3595704

Browse files
refactor: specify CultureInfo when parsing DateOnly and added AttributeUsage to ValidDateOnlyAttribute
1 parent 48e068c commit 3595704

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/ServiceLayer.API/Functions/BSSelectFunctions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.ComponentModel.DataAnnotations;
2+
using System.Globalization;
23
using System.Text.Json;
34
using Azure.Messaging;
45
using Azure.Messaging.EventGrid;
@@ -46,7 +47,7 @@ public async Task<IActionResult> IngressEpisode([HttpTrigger(AuthorizationLevel.
4647
PathwayTypeName = "Breast Screening Routine",
4748
ScreeningName = "Breast Screening",
4849
NhsNumber = bssEpisodeEvent.NhsNumber!,
49-
DOB = DateOnly.Parse(bssEpisodeEvent.DateOfBirth!),
50+
DOB = DateOnly.Parse(bssEpisodeEvent.DateOfBirth!, CultureInfo.CurrentCulture),
5051
Name = $"{bssEpisodeEvent.FirstGivenName} {bssEpisodeEvent.FamilyName}",
5152
};
5253

src/ServiceLayer.API/Shared/ValidDateOnlyAttribute.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
using System.ComponentModel.DataAnnotations;
2+
using System.Globalization;
23

34
namespace ServiceLayer.API.Shared;
45

6+
[AttributeUsage(AttributeTargets.Property)]
57
public class ValidDateOnlyAttribute : ValidationAttribute
68
{
79
public override bool IsValid(object? value)
810
{
9-
if (value is string s && DateOnly.TryParse(s, out _))
11+
if (value is string s && DateOnly.TryParse(s, CultureInfo.CurrentCulture, out _))
1012
{
1113
return true;
1214
}

0 commit comments

Comments
 (0)