Merged in fix/SW-2950-validation-rule-for-zipcode- (pull request #2360)

Fix: SW-2950 Updated zip code validation rule with regex

* Fix: SW-2950 Updated zip code validation rule with regex

* fix: SW-2950 Removed non-english characters from postal code regex


Approved-by: Christian Andolf
This commit is contained in:
Hrishikesh Vaipurkar
2025-06-16 08:32:46 +00:00
parent ac0145e562
commit 698c424f21
4 changed files with 21 additions and 3 deletions

View File

@@ -15,6 +15,7 @@ export const signupErrors = {
PASSWORD_REQUIRED: "PASSWORD_REQUIRED",
TERMS_REQUIRED: "TERMS_REQUIRED",
ZIP_CODE_REQUIRED: "ZIP_CODE_REQUIRED",
ZIP_CODE_INVALID: "ZIP_CODE_INVALID",
} as const
export const signUpSchema = z.object({
@@ -44,7 +45,10 @@ export const signUpSchema = z.object({
invalid_type_error: signupErrors.COUNTRY_REQUIRED,
})
.min(1, signupErrors.COUNTRY_REQUIRED),
zipCode: z.string().min(1, signupErrors.ZIP_CODE_REQUIRED),
zipCode: z
.string()
.min(1, signupErrors.ZIP_CODE_REQUIRED)
.regex(/^[A-Za-z0-9-\s]{1,9}$/g, signupErrors.ZIP_CODE_INVALID),
}),
password: passwordValidator(signupErrors.PASSWORD_REQUIRED),
termsAccepted: z