Skip to content

Commit 56bbbac

Browse files
More phone issues
An example of a phone that recently failed validation: (XXX) XXX-XXXX. We already strip the paren and the dash, but I guess we don't strip the spaces from the middle of the number, so doing that now.
1 parent baedb72 commit 56bbbac

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

proxyserver/src/main/java/edu/suffolk/litlab/efsp/server/ecf4/EcfCourtSpecificSerializer.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,18 @@ public ContactInformationType serializeEcfContactInformation(
523523
boolean atLeastOnePhoneAdded = false;
524524
for (String phoneNumber : numbers) {
525525
if (!phoneRow.matchRegex(phoneNumber)) {
526-
if (phoneNumber.contains("-")) {
526+
if (phoneNumber.contains("-")
527+
|| phoneNumber.contains("(")
528+
|| phoneNumber.contains(")")
529+
|| phoneNumber.contains(" ")) {
527530
// HACK(brycew): Massachusetts doesn't like dashes in the number, just numbers
528-
phoneNumber = phoneNumber.replace("-", "").replace("(", "").replace(")", "").strip();
531+
phoneNumber =
532+
phoneNumber
533+
.replace("-", "")
534+
.replace("(", "")
535+
.replace(")", "")
536+
.strip()
537+
.replace(" ", "");
529538
}
530539
if (!phoneRow.matchRegex(phoneNumber)) {
531540
continue;

proxyserver/src/test/java/edu/suffolk/litlab/efsp/server/ecf4/EcfCourtSpecificSerializerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,14 @@ public void shouldAllowAtLeastOnePhone() throws FilingError {
184184
collector = new AllWrongCollector();
185185
ContactInformation info =
186186
new ContactInformation(
187-
List.of("1234567890", "123-456-7890 ", "123-abc"),
187+
List.of("1234567890", "123-456-7890 ", "123-abc", "(123) 456-7890"),
188188
Optional.empty(),
189189
Optional.of("bob@example.com"));
190190
CourtLocationInfo loc = new CourtLocationInfo();
191191
loc.code = "not_real";
192192
EcfCourtSpecificSerializer courtSer = new EcfCourtSpecificSerializer(cd, loc);
193193
var contactInfoType = courtSer.serializeEcfContactInformation(info, collector);
194-
assertThat(contactInfoType.getContactMeans()).hasSize(2);
194+
assertThat(contactInfoType.getContactMeans()).hasSize(3);
195195
assertThat(collector.getWrong()).hasSize(0);
196196
}
197197

0 commit comments

Comments
 (0)