Skip to content

Commit 03de43f

Browse files
authored
fix: relax NATIONAL_ID regex to accept short codes like DCC (#2167)
* fix: relax NATIONAL_ID external reference regex to accept short codes The national ID regex required 5-20 characters, rejecting legitimate short codes like DCC (3 chars), GETW (4 chars), and SEPD (4 chars) used in the PAYG energy manifest. This caused the nightly Demo Reset workflow to fail on every run since the PAYG tenant was added. Lowered the minimum from 5 to 2 characters. * fix: update boundary tests for relaxed NATIONAL_ID regex Update minimum length test to use 2-char reference and too-short test to use 1-char reference, matching the new {2,20} constraint. --------- Co-authored-by: Ben Coombs <bjcoombs@users.noreply.github.com>
1 parent 43dddc7 commit 03de43f

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

services/party/domain/party.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,8 @@ var (
607607
// LEI: 20 alphanumeric characters
608608
leiRegex = regexp.MustCompile(`^[A-Z0-9]{20}$`)
609609

610-
// National ID: varies by country, using a general alphanumeric pattern
611-
nationalIDRegex = regexp.MustCompile(`^[A-Z0-9]{5,20}$`)
610+
// National ID: varies by country, using a general alphanumeric pattern (min 2 for short codes like DCC)
611+
nationalIDRegex = regexp.MustCompile(`^[A-Z0-9]{2,20}$`)
612612

613613
// Tax ID: varies by country, using a general alphanumeric pattern
614614
taxIDRegex = regexp.MustCompile(`^[A-Z0-9]{5,20}$`)

services/party/domain/party_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ func TestParty_SetExternalReference_NationalID(t *testing.T) {
357357
},
358358
{
359359
name: "minimum length",
360-
reference: "AB123",
360+
reference: "AB",
361361
wantErr: false,
362362
},
363363
{
@@ -367,7 +367,7 @@ func TestParty_SetExternalReference_NationalID(t *testing.T) {
367367
},
368368
{
369369
name: "too short",
370-
reference: "AB12",
370+
reference: "A",
371371
wantErr: true,
372372
},
373373
{
@@ -517,6 +517,12 @@ func TestValidateExternalReference(t *testing.T) {
517517
refType: ExternalReferenceTypeNationalID,
518518
wantErr: false,
519519
},
520+
{
521+
name: "valid short national ID",
522+
reference: "DCC",
523+
refType: ExternalReferenceTypeNationalID,
524+
wantErr: false,
525+
},
520526
{
521527
name: "valid tax ID",
522528
reference: "GB123456789",

0 commit comments

Comments
 (0)