mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
Update profile schema
This commit is contained in:
@@ -2,27 +2,28 @@ import { z } from 'zod';
|
|||||||
|
|
||||||
const UpdateProfileSchema = z.object({
|
const UpdateProfileSchema = z.object({
|
||||||
bio: z.string().min(1, 'Bio cannot be empty'),
|
bio: z.string().min(1, 'Bio cannot be empty'),
|
||||||
userAvatar: z.optional(
|
userAvatar: z
|
||||||
z
|
.instanceof(typeof FileList !== 'undefined' ? FileList : Object)
|
||||||
.instanceof(typeof FileList !== 'undefined' ? FileList : Object)
|
.refine((fileList) => fileList instanceof FileList, {
|
||||||
.refine((fileList) => fileList instanceof FileList, {
|
message: 'You must submit this form in a web browser.',
|
||||||
message: 'You must submit this form in a web browser.',
|
})
|
||||||
})
|
.refine((fileList) => [...(fileList as FileList)].length === 1, {
|
||||||
.refine(
|
message: 'You must upload one file.',
|
||||||
(fileList) =>
|
})
|
||||||
[...(fileList as FileList)]
|
.refine(
|
||||||
.map((file) => file.type)
|
(fileList) =>
|
||||||
.every((fileType) => fileType.startsWith('image/')),
|
[...(fileList as FileList)]
|
||||||
{ message: 'You must upload only images.' },
|
.map((file) => file.type)
|
||||||
)
|
.every((fileType) => fileType.startsWith('image/')),
|
||||||
.refine(
|
{ message: 'You must upload only images.' },
|
||||||
(fileList) =>
|
)
|
||||||
[...(fileList as FileList)]
|
.refine(
|
||||||
.map((file) => file.size)
|
(fileList) =>
|
||||||
.every((fileSize) => fileSize < 15 * 1024 * 1024),
|
[...(fileList as FileList)]
|
||||||
{ message: 'You must upload images smaller than 15MB.' },
|
.map((file) => file.size)
|
||||||
),
|
.every((fileSize) => fileSize < 15 * 1024 * 1024),
|
||||||
),
|
{ message: 'You must upload images smaller than 15MB.' },
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default UpdateProfileSchema;
|
export default UpdateProfileSchema;
|
||||||
|
|||||||
Reference in New Issue
Block a user