Skip to content

Commit fb99988

Browse files
TD-4624 error message to describe exactly what’s allowed
1 parent e4edffc commit fb99988

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

DigitalLearningSolutions.Web.Tests/Controllers/TrackingSystem/Delegates/EditDelegateControllerTests.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,11 @@ public void Index_post_returns_view_with_model_error_with_invalid_prn()
175175
result.As<ViewResult>().Model.Should().BeOfType<EditDelegateViewModel>();
176176
AssertModelStateErrorIsExpected(
177177
result,
178-
"Invalid professional registration number format. Accepted formats are: 1–2 letters followed by 6 digits (e.g., AB123456)" +
179-
" 4–8 digits only " + "Optional ‘P’ followed by 5–6 digits ‘C’ or ‘P’ followed by 6 digits " +
180-
"Optional letter followed by 5–6 digits ‘L’ followed by 4–6 digits 2 digits, hyphen, then 4–5 alphanumeric characters"
178+
"Invalid professional registration number format. " +
179+
"Valid formats include: 7 digits (e.g., 1234567), 1–2 letters followed by 6 digits (e.g., AB123456), " +
180+
"4–8 digits, an optional 'P' plus 5–6 digits, 'C' or 'P' plus 6 digits, " +
181+
"an optional letter plus 5–6 digits, 'L' plus 4–6 digits, " +
182+
"or 2 digits followed by a hyphen and 4–5 alphanumeric characters (e.g., 12-AB123)."
181183

182184
);
183185
A.CallTo(() => userService.GetDelegateById(A<int>._)).MustNotHaveHappened();

DigitalLearningSolutions.Web.Tests/Helpers/ProfessionalRegistrationNumberHelperTests.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,29 @@ public void ValidateProfessionalRegistrationNumber_sets_error_when_hasPrn_is_not
110110
[TestCase("1234", "Professional registration number must be between 5 and 20 characters")]
111111
[TestCase(
112112
"01234_",
113-
"Invalid professional registration number format. Accepted formats are: 1–2 letters followed by 6 digits (e.g., AB123456)" +
114-
" 4–8 digits only " + "Optional ‘P’ followed by 5–6 digits ‘C’ or ‘P’ followed by 6 digits " +
115-
"Optional letter followed by 5–6 digits ‘L’ followed by 4–6 digits 2 digits, hyphen, then 4–5 alphanumeric characters"
113+
"Invalid professional registration number format. " +
114+
"Valid formats include: 7 digits (e.g., 1234567), 1–2 letters followed by 6 digits (e.g., AB123456), " +
115+
"4–8 digits, an optional 'P' plus 5–6 digits, 'C' or 'P' plus 6 digits, " +
116+
"an optional letter plus 5–6 digits, 'L' plus 4–6 digits, " +
117+
"or 2 digits followed by a hyphen and 4–5 alphanumeric characters (e.g., 12-AB123)."
116118

117119
)]
118120
[TestCase(
119121
"01234 ",
120-
"Invalid professional registration number format. Accepted formats are: 1–2 letters followed by 6 digits (e.g., AB123456)" +
121-
" 4–8 digits only " + "Optional ‘P’ followed by 5–6 digits ‘C’ or ‘P’ followed by 6 digits " +
122-
"Optional letter followed by 5–6 digits ‘L’ followed by 4–6 digits 2 digits, hyphen, then 4–5 alphanumeric characters"
122+
"Invalid professional registration number format. " +
123+
"Valid formats include: 7 digits (e.g., 1234567), 1–2 letters followed by 6 digits (e.g., AB123456), " +
124+
"4–8 digits, an optional 'P' plus 5–6 digits, 'C' or 'P' plus 6 digits, " +
125+
"an optional letter plus 5–6 digits, 'L' plus 4–6 digits, " +
126+
"or 2 digits followed by a hyphen and 4–5 alphanumeric characters (e.g., 12-AB123)."
123127

124128
)]
125129
[TestCase(
126130
"01234$",
127-
"Invalid professional registration number format. Accepted formats are: 1–2 letters followed by 6 digits (e.g., AB123456)" +
128-
" 4–8 digits only " + "Optional ‘P’ followed by 5–6 digits ‘C’ or ‘P’ followed by 6 digits " +
129-
"Optional letter followed by 5–6 digits ‘L’ followed by 4–6 digits 2 digits, hyphen, then 4–5 alphanumeric characters"
131+
"Invalid professional registration number format. " +
132+
"Valid formats include: 7 digits (e.g., 1234567), 1–2 letters followed by 6 digits (e.g., AB123456), " +
133+
"4–8 digits, an optional 'P' plus 5–6 digits, 'C' or 'P' plus 6 digits, " +
134+
"an optional letter plus 5–6 digits, 'L' plus 4–6 digits, " +
135+
"or 2 digits followed by a hyphen and 4–5 alphanumeric characters (e.g., 12-AB123)."
130136

131137
)]
132138
public void ValidateProfessionalRegistrationNumber_sets_error_when_prn_is_invalid(

DigitalLearningSolutions.Web/Helpers/ProfessionalRegistrationNumberHelper.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ public static void ValidateProfessionalRegistrationNumber(
5858
{
5959
modelState.AddModelError(
6060
"ProfessionalRegistrationNumber",
61-
"Invalid professional registration number format. Accepted formats are: 1–2 letters followed by 6 digits (e.g., AB123456)"+
62-
" 4–8 digits only "+"Optional ‘P’ followed by 5–6 digits ‘C’ or ‘P’ followed by 6 digits "+
63-
"Optional letter followed by 5–6 digits ‘L’ followed by 4–6 digits 2 digits, hyphen, then 4–5 alphanumeric characters"
61+
"Invalid professional registration number format. " +
62+
"Valid formats include: 7 digits (e.g., 1234567), 1–2 letters followed by 6 digits (e.g., AB123456), " +
63+
"4–8 digits, an optional 'P' plus 5–6 digits, 'C' or 'P' plus 6 digits, " +
64+
"an optional letter plus 5–6 digits, 'L' plus 4–6 digits, " +
65+
"or 2 digits followed by a hyphen and 4–5 alphanumeric characters (e.g., 12-AB123)."
6466
);
6567
}
6668
}

0 commit comments

Comments
 (0)