UNPKG

ratemypackage

Version:

RateMyPackage is a shared library designed to streamline development for the RateMyCampus project. It provides a collection of reusable types, interfaces, and utility functions to support both frontend and backend operations. By centralizing common logic

104 lines 3.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.editProfileSchema = exports.passwordSchema = exports.commentSchema = exports.postSchema = exports.uniSchema = exports.userSchema = void 0; const zod_1 = require("zod"); const fileValidation = zod_1.z.custom((val) => val instanceof File, { message: "Invalid file", }); exports.userSchema = zod_1.z.object({ email: zod_1.z .string({ required_error: "Email is required", invalid_type_error: "Email must be a string", }) .email({ message: "Invalid email address" }), fullName: zod_1.z.string({ required_error: "Fullname is required", invalid_type_error: "Fullname must be a string", }), password: zod_1.z .string({ required_error: "Password is required", invalid_type_error: "Password must be a string", }) .min(8, { message: "Password must be 8 character long" }), profilePhoto: fileValidation.optional().nullable(), }); exports.uniSchema = zod_1.z.object({ name: zod_1.z.string({ required_error: "University name is required", invalid_type_error: "University name must be a string", }), fee: zod_1.z.string({ required_error: "University fee is required", invalid_type_error: "University fee must be a string", }), topField: zod_1.z.string({ required_error: "University's top field is required", invalid_type_error: "University's top field must be a string", }), status: zod_1.z.string({ required_error: "University status is required", invalid_type_error: "University status must be a string", }), mainCampus: zod_1.z.string({ required_error: "University main campus is required", invalid_type_error: "Main Campus must be a string", }), campuses: zod_1.z.string({ required_error: "How many campuses?", invalid_type_error: "Campuses must be string", }), logo: fileValidation, coverPhoto: fileValidation, }); exports.postSchema = zod_1.z.object({ content: zod_1.z .string({ invalid_type_error: "Content must be string" }) .max(500, "Post cannot exceed 500 characters") .optional() .nullable(), universityId: zod_1.z.number({ required_error: "Univeristy ID is required", invalid_type_error: "University ID must be a number!", }), userId: zod_1.z.number({ required_error: "User ID is required", invalid_type_error: "User ID must be a number!", }), photo: fileValidation.optional().nullable(), }); exports.commentSchema = zod_1.z.object({ comment: zod_1.z.string().max(150, "Comment cannot exceed 150 characters"), userId: zod_1.z.number({ required_error: "User ID is required", invalid_type_error: "User ID must be a number!", }), postId: zod_1.z.number({ required_error: "Post ID is required", invalid_type_error: "Post ID must be a number!", }), }); exports.passwordSchema = zod_1.z .string({ required_error: "Password is required", invalid_type_error: "Password must be string", }) .min(8, { message: "Password must be 8 character long" }); exports.editProfileSchema = zod_1.z.object({ fullName: zod_1.z .string({ invalid_type_error: "Fullname must be a string", }) .optional() .nullable(), password: zod_1.z .string({ invalid_type_error: "Password must be a string", }) .min(8, { message: "Password must be 8 character long" }) .optional() .nullable(), profilePhoto: fileValidation.optional().nullable(), }); //# sourceMappingURL=types.js.map