From b9ff25edd2ca0e3f58bb8809d460dc702d22b5b4 Mon Sep 17 00:00:00 2001 From: samaradel Date: Sun, 13 Oct 2024 14:09:05 +0300 Subject: [PATCH] Remove number validator of first char and add test case for it --- packages/playground/src/components/smtp_server.vue | 2 +- .../utils/validators/IsAlphaExpectDashAndUnderscore.test.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/playground/src/components/smtp_server.vue b/packages/playground/src/components/smtp_server.vue index a29a4fa3e8..0ec0f099a8 100644 --- a/packages/playground/src/components/smtp_server.vue +++ b/packages/playground/src/components/smtp_server.vue @@ -28,7 +28,7 @@ validators.isEmail('Please provide a valid email address.')(v) && (validators.IsAlphaExpectDashAndUnderscore( 'Username should consist of letters, dashs and underscores only.' - )(v) || validators.isAlpha('Username must start with an alphabetical character.')(v[0])) + )(v)) ); }, ]" diff --git a/packages/playground/tests/utils/validators/IsAlphaExpectDashAndUnderscore.test.ts b/packages/playground/tests/utils/validators/IsAlphaExpectDashAndUnderscore.test.ts index 70278be7c1..765efc6b88 100644 --- a/packages/playground/tests/utils/validators/IsAlphaExpectDashAndUnderscore.test.ts +++ b/packages/playground/tests/utils/validators/IsAlphaExpectDashAndUnderscore.test.ts @@ -35,4 +35,9 @@ describe("IsAlphaExpectDashAndUnderscore", () => { const result = validator("hello"); expect(result).toBeUndefined(); }); + + it("returns undefined for valid username/email that starts with numbers", () => { + const result = validator("4me"); + expect(result).toBeUndefined(); + }); });