Skip to content

Commit b49f411

Browse files
chore: addressing comments on PR
1 parent 3161581 commit b49f411

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

application/CohortManager/src/Functions/CohortDistributionServices/TransformDataService/TransformDataLookupFacade.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,13 @@ public async Task<HashSet<string>> GetCachedExcludedSMUValues()
6363

6464
public bool ValidateOutcode(string postcode)
6565
{
66-
var parsedOutCode = ValidationHelper.ParseOutcode(postcode);
67-
_ = parsedOutCode
66+
//if a postcode is a dummy postcode then we want to allow the rules to know that we have a dummy postcode
67+
if (postcode.StartsWith("ZZ"))
68+
{
69+
return false;
70+
}
71+
72+
string parsedOutCode = ValidationHelper.ParseOutcode(postcode)
6873
?? throw new TransformationException("Postcode format invalid");
6974

7075
var result = _outcodeClient.GetSingle(parsedOutCode).Result;

application/CohortManager/src/Functions/Shared/Common/ValidationHelper.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public static bool ValidatePostcode(string postcode)
103103
}
104104

105105
/// <summary>
106-
/// Gets the outcode (1st part of postcode) from the postcode and if the postcode is a dummy code
106+
/// Gets the outcode (1st part of postcode) from the postcode.
107107
/// </summary>
108108
/// <param name="postcode">a non-null string representing the postcode</param>
109109
/// <remarks>
@@ -113,15 +113,8 @@ public static bool ValidatePostcode(string postcode)
113113
public static string? ParseOutcode(string postcode)
114114
{
115115
string pattern = @"^([A-Za-z][A-Za-z]?[0-9][A-Za-z0-9]?) ?[0-9][A-Za-z]{2}$";
116-
string specialDummyOutCodePattern = "^ZZ99|^ZZZSECUR$";
117116

118117
Match match = Regex.Match(postcode, pattern, RegexOptions.IgnoreCase, TimeSpan.FromSeconds(2));
119-
Match dummyOutCodePattern = Regex.Match(postcode, specialDummyOutCodePattern, RegexOptions.IgnoreCase, TimeSpan.FromSeconds(2));
120-
121-
if (dummyOutCodePattern.Success)
122-
{
123-
return dummyOutCodePattern.Groups[1].Value;
124-
}
125118

126119
if (!match.Success)
127120
{

0 commit comments

Comments
 (0)