All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 50s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
28 lines
912 B
TypeScript
28 lines
912 B
TypeScript
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<string, unknown>;
|
|
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<string, unknown>;
|
|
return typeof o.body === "string" &&
|
|
(o.body as string).trim().length > 0 &&
|
|
(o.body as string).length <= VALIDATION.COMMENT_BODY_MAX;
|
|
}
|