Update profile schema

This commit is contained in:
Aaron William Po
2023-12-02 14:15:32 -05:00
parent 415f1b6a30
commit 0d23b02957

View File

@@ -2,12 +2,14 @@ import { z } from 'zod';
const UpdateProfileSchema = z.object({
bio: z.string().min(1, 'Bio cannot be empty'),
userAvatar: z.optional(
z
userAvatar: z
.instanceof(typeof FileList !== 'undefined' ? FileList : Object)
.refine((fileList) => fileList instanceof FileList, {
message: 'You must submit this form in a web browser.',
})
.refine((fileList) => [...(fileList as FileList)].length === 1, {
message: 'You must upload one file.',
})
.refine(
(fileList) =>
[...(fileList as FileList)]
@@ -22,7 +24,6 @@ const UpdateProfileSchema = z.object({
.every((fileSize) => fileSize < 15 * 1024 * 1024),
{ message: 'You must upload images smaller than 15MB.' },
),
),
});
export default UpdateProfileSchema;