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:
@@ -6,6 +6,7 @@ import { phoneValidator } from "@/utils/zod/phoneValidator"
|
||||
export const editProfileErrors = {
|
||||
COUNTRY_REQUIRED: "COUNTRY_REQUIRED",
|
||||
ZIP_CODE_REQUIRED: "ZIP_CODE_REQUIRED",
|
||||
ZIP_CODE_INVALID: "ZIP_CODE_INVALID",
|
||||
PHONE_REQUIRED: "PHONE_REQUIRED",
|
||||
PHONE_REQUESTED: "PHONE_REQUESTED",
|
||||
PASSWORD_NEW_REQUIRED: "PASSWORD_NEW_REQUIRED",
|
||||
@@ -25,7 +26,10 @@ export const editProfileSchema = z
|
||||
})
|
||||
.min(1, editProfileErrors.COUNTRY_REQUIRED),
|
||||
streetAddress: z.string().optional(),
|
||||
zipCode: z.string().min(1, editProfileErrors.ZIP_CODE_REQUIRED),
|
||||
zipCode: z
|
||||
.string()
|
||||
.min(1, editProfileErrors.ZIP_CODE_REQUIRED)
|
||||
.regex(/^[A-Za-z0-9-\s]{1,9}$/g, editProfileErrors.ZIP_CODE_INVALID),
|
||||
}),
|
||||
dateOfBirth: z.string().min(1),
|
||||
email: z.string().email(),
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -23,6 +23,7 @@ export const roomOneErrors = {
|
||||
MEMBERSHIP_NO_ONLY_DIGITS: "MEMBERSHIP_NO_ONLY_DIGITS",
|
||||
MEMBERSHIP_NO_INVALID: "MEMBERSHIP_NO_INVALID",
|
||||
ZIP_CODE_REQUIRED: "ZIP_CODE_REQUIRED",
|
||||
ZIP_CODE_INVALID: "ZIP_CODE_INVALID",
|
||||
BIRTH_DATE_REQUIRED: "BIRTH_DATE_REQUIRED",
|
||||
BIRTH_DATE_AGE_18: "BIRTH_DATE_AGE_18",
|
||||
} as const
|
||||
@@ -72,7 +73,10 @@ export const notJoinDetailsSchema = baseDetailsSchema.merge(
|
||||
export const joinDetailsSchema = baseDetailsSchema.merge(
|
||||
z.object({
|
||||
join: z.literal<boolean>(true),
|
||||
zipCode: z.string().min(1, roomOneErrors.ZIP_CODE_REQUIRED),
|
||||
zipCode: z
|
||||
.string()
|
||||
.min(1, roomOneErrors.ZIP_CODE_REQUIRED)
|
||||
.regex(/^[A-Za-z0-9-\s]{1,9}$/g, roomOneErrors.ZIP_CODE_INVALID),
|
||||
dateOfBirth: z
|
||||
.string()
|
||||
.min(1, roomOneErrors.BIRTH_DATE_REQUIRED)
|
||||
|
||||
@@ -103,6 +103,12 @@ export function getErrorMessage(intl: IntlShape, errorCode?: string) {
|
||||
return intl.formatMessage({
|
||||
defaultMessage: "Zip code is required",
|
||||
})
|
||||
case roomOneErrors.ZIP_CODE_INVALID:
|
||||
case editProfileErrors.ZIP_CODE_INVALID:
|
||||
case signupErrors.ZIP_CODE_INVALID:
|
||||
return intl.formatMessage({
|
||||
defaultMessage: "The postal code can only contain numbers and letters",
|
||||
})
|
||||
case signupErrors.PASSWORD_REQUIRED:
|
||||
return intl.formatMessage({
|
||||
defaultMessage: "Password is required",
|
||||
|
||||
Reference in New Issue
Block a user