chore: Update api service type directories to maintain consistency

This commit is contained in:
Aaron William Po
2023-07-07 23:23:04 -04:00
parent ee47f99f8a
commit 5292c47a2a
69 changed files with 99 additions and 99 deletions

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,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;