// BABYBOO-43: the reason every admin rank or referral correction carries. The limit matches the // backend (member.remarks / sponsor_history.remarks are varchar(255)); mobile-api re-validates. export const MAX_CORRECTION_REASON_LENGTH = 255; export type ReasonCheck = { ok: true; reason: string } | { ok: false; error: string }; /** Trims the reason and checks it is present and short enough. Errors are English API messages. */ export function checkCorrectionReason(reason: unknown): ReasonCheck { const trimmed = typeof reason === "string" ? reason.trim() : ""; if (!trimmed) return { ok: false, error: "A reason is required." }; if (trimmed.length > MAX_CORRECTION_REASON_LENGTH) { return { ok: false, error: "The reason must be 255 characters or fewer." }; } return { ok: true, reason: trimmed }; }