mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-10-15 18:14:44 +00:00
Move next js project to archive (#207)
This commit is contained in:
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user