import { MAX_BODY_LENGTH, MAX_TITLE_LENGTH } from "./contract/limits.ts"; export function titleError(title: string): string | undefined { if (!title || title.length > MAX_TITLE_LENGTH) return `Title must be 1–${MAX_TITLE_LENGTH} characters.`; } export function bodyError(body: string, what = "Description"): string | undefined { if (body.length > MAX_BODY_LENGTH) return `${what} is too long.`; } /** A body that must not be empty, such as a comment or a reply. */ export function requiredBodyError(body: string, what: string, empty: string): string | undefined { return body ? bodyError(body, what) : empty; }