diff --git a/src/main/common/form/validators/emailValidator.ts b/src/main/common/form/validators/emailValidator.ts index 7481352362d..5d6d2c9e9ab 100644 --- a/src/main/common/form/validators/emailValidator.ts +++ b/src/main/common/form/validators/emailValidator.ts @@ -8,7 +8,7 @@ import validator from 'validator'; export class EmailValidator implements ValidatorConstraintInterface { //eslint-disable-next-line readonly EMAIL_REGEX = /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/; - readonly EMAIL_MAX_LENGTH = 40; + readonly EMAIL_MAX_LENGTH = 320; validate(value: string) { const emailPattern = this.EMAIL_REGEX; diff --git a/src/test/unit/routes/features/claim/defendantEmailController.test.ts b/src/test/unit/routes/features/claim/defendantEmailController.test.ts index a051e8d797c..15e3366ece0 100644 --- a/src/test/unit/routes/features/claim/defendantEmailController.test.ts +++ b/src/test/unit/routes/features/claim/defendantEmailController.test.ts @@ -93,9 +93,10 @@ describe('Completing Claim', () => { it('should return error on input too long', async () => { app.locals.draftStoreClient = mockCivilClaim; + const greaterThan320CharsEmail = 'x'.repeat(311) + '@gmail.com'; await request(app) .post(CLAIM_DEFENDANT_EMAIL_URL) - .send({emailAddress: 'thisislongerthanfortycharacters@gmail.com'}) + .send({emailAddress: greaterThan320CharsEmail}) .expect((res) => { expect(res.status).toBe(200); expect(res.text).toContain(TestMessages.ENTER_VALID_EMAIL);