💥 add basic fetch user via email

This commit is contained in:
Rafi Arrafif
2025-07-17 18:36:06 +07:00
parent ea96d160bd
commit 30806e23e0
10 changed files with 74 additions and 33 deletions

View File

@ -1,24 +0,0 @@
import Joi from "joi";
export const editUserSchema = Joi.object({
name: Joi.string()
.min(4)
.max(255),
username: Joi.string()
.min(4)
.max(255),
birthdate: Joi.date(),
gender: Joi.string().valid("male", "female"),
phoneCC: Joi.string()
.min(2)
.max(2),
phoneNumber: Joi.string()
.min(7)
.max(15),
bioProfile: Joi.string().max(300),
deletedAt: Joi.date(),
// validate in helper
avatar: Joi.any(),
commentBackground: Joi.any(),
});

View File

@ -0,0 +1,5 @@
import z from "zod";
export const getUserByIdSchema = z.object({
email: z.email(),
});

View File

@ -0,0 +1,20 @@
import z from "zod";
const includeEnum = z.enum(
["preference", "roles"],
"option: include value didn't match with enum types"
);
export const getUserOptionsSchema = z.object({
verbosity: z
.enum(
["exists", "basic", "full"],
"option: verbosity value didn't match with enum types"
)
.optional(),
include: z.preprocess((val) => {
if (Array.isArray(val)) return val;
if (typeof val === "string") return [val];
return [];
}, z.array(includeEnum).optional()),
});