feat: validate optional membership number for non-logged in users
This commit is contained in:
@@ -16,6 +16,21 @@ export const notJoinDetailsSchema = baseDetailsSchema.merge(
|
||||
zipCode: z.string().optional(),
|
||||
dateOfBirth: z.string().optional(),
|
||||
termsAccepted: z.boolean().default(false),
|
||||
membershipNo: z
|
||||
.string()
|
||||
.optional()
|
||||
.refine((val) => {
|
||||
if (val) {
|
||||
return !val.match(/[^0-9]/g)
|
||||
}
|
||||
return true
|
||||
}, "Only digits are allowed")
|
||||
.refine((num) => {
|
||||
if (num) {
|
||||
return num.length === 14
|
||||
}
|
||||
return true
|
||||
}, "Membership number needs to be 14 digits"),
|
||||
})
|
||||
)
|
||||
|
||||
@@ -33,6 +48,7 @@ export const joinDetailsSchema = baseDetailsSchema.merge(
|
||||
return { message: ctx.defaultError }
|
||||
},
|
||||
}),
|
||||
membershipNo: z.string().optional(),
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user