import type { CreateCommentRequest, UpdateCommentRequest, } from "../../shared/comment.ts"; import { VALIDATION } from "../../shared/validation.ts"; export function isCreateCommentRequest( obj: unknown, ): obj is CreateCommentRequest { if (!obj || typeof obj !== "object") return false; const o = obj as Record; return typeof o.body === "string" && (o.body as string).trim().length > 0 && (o.body as string).length <= VALIDATION.COMMENT_BODY_MAX && (!("parentId" in o) || typeof o.parentId === "string" || o.parentId === null); } export function isUpdateCommentRequest( obj: unknown, ): obj is UpdateCommentRequest { if (!obj || typeof obj !== "object") return false; const o = obj as Record; return typeof o.body === "string" && (o.body as string).trim().length > 0 && (o.body as string).length <= VALIDATION.COMMENT_BODY_MAX; }