Move next js project to archive (#207)

This commit is contained in:
Aaron Po
2026-04-20 02:30:25 -04:00
committed by GitHub
parent 92ec16ce93
commit d47e3ed7f0
347 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
import { z } from 'zod';
import ImageQueryValidationSchema from '../ImageSchema/ImageQueryValidationSchema';
const CommentQueryResult = z.object({
id: z.string().cuid(),
content: z.string().min(1).max(500),
rating: z.number().int().min(1).max(5),
createdAt: z.coerce.date(),
updatedAt: z.coerce.date().nullable(),
postedBy: z.object({
id: z.string().cuid(),
username: z.string().min(1).max(50),
userAvatar: ImageQueryValidationSchema.nullable(),
}),
});
export default CommentQueryResult;

View File

@@ -0,0 +1,15 @@
import { z } from 'zod';
const CreateCommentValidationSchema = z.object({
content: z
.string()
.min(1, { message: 'Comment must not be empty.' })
.max(300, { message: 'Comment must be less than 300 characters.' }),
rating: z
.number()
.int()
.min(1, { message: 'Rating must be greater than 1.' })
.max(5, { message: 'Rating must be less than 5.' }),
});
export default CreateCommentValidationSchema;

View File

@@ -0,0 +1,8 @@
import { z } from 'zod';
const ImageMetadataValidationSchema = z.object({
caption: z.string().min(1, { message: 'Caption is required.' }),
alt: z.string().min(1, { message: 'Alt text is required.' }),
});
export default ImageMetadataValidationSchema;

View File

@@ -0,0 +1,12 @@
import { z } from 'zod';
const ImageQueryValidationSchema = z.object({
id: z.string().cuid(),
path: z.string().url(),
alt: z.string(),
caption: z.string(),
createdAt: z.coerce.date(),
updatedAt: z.coerce.date().nullable(),
});
export default ImageQueryValidationSchema;

View File

@@ -0,0 +1,31 @@
import { z } from 'zod';
const UploadImageValidationSchema = z.object({
images: 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 > 0, {
message: 'You must upload at least one file.',
})
.refine((fileList) => (fileList as FileList).length < 5, {
message: 'You can only upload up to 5 files at a time.',
})
.refine(
(fileList) =>
[...(fileList as FileList)]
.map((file) => file.type)
.every((fileType) => fileType.startsWith('image/')),
{ message: 'You must upload only images.' },
)
.refine(
(fileList) =>
[...(fileList as FileList)]
.map((file) => file.size)
.every((fileSize) => fileSize < 15 * 1024 * 1024),
{ message: 'You must upload images smaller than 15MB.' },
),
});
export default UploadImageValidationSchema;

View File

@@ -0,0 +1,8 @@
import { z } from 'zod';
const PaginatedQueryResponseSchema = z.object({
page_num: z.string().regex(/^\d+$/),
page_size: z.string().regex(/^\d+$/),
});
export default PaginatedQueryResponseSchema;