/** 셀/푸터 검증 오류 한 건 (입력 조회 verificationResult 항목) */ export type VerificationResultLikeItem = { vrfcCd: string; rsnExpln: string; nowCn?: string; cmprCn?: string; nowVlCn?: string; compVlCn?: string; }; export type VerificationResultLikeMap = Record< string, VerificationResultLikeItem[] >; /** 검증 오류 배열 → RealGrid styleName */ export function getVerificationStyleName( errors: VerificationResultLikeItem[] | null | undefined, ): string | undefined { if (!Array.isArray(errors) || errors.length === 0) return undefined; const hasImr = errors.some( (e) => e.vrfcCd === "IMR" || e.vrfcCd === "HB", ); return hasImr ? "rg-cell-verify-error-imr" : "rg-cell-verify-error"; } /** 검증 오류 배열 → 툴팁/메시지 문구 */ export function formatVerificationTooltip( errors: VerificationResultLikeItem[] | null | undefined, ): string | undefined { if (!Array.isArray(errors) || errors.length === 0) return undefined; const text = errors .map((e) => { const prefix = e.vrfcCd === "IMR" ? "시계열 검증 - " : e.vrfcCd === "NV" ? "일반검증 - " : "모집단 검증 - "; const comp = e.cmprCn ?? e.compVlCn ?? ""; const now = e.nowCn ?? e.nowVlCn ?? ""; return `${prefix}${e.rsnExpln}\n(검증 기준값: ${comp} / 현재 입력값: ${now})`; }) .filter(Boolean) .join("\n"); return text.length > 0 ? text : undefined; } /** fieldName 및 alias 중 첫 매칭 오류 배열 */ export function getVerificationErrorsForField( result: VerificationResultLikeMap | null | undefined, fieldName: string, aliases?: readonly string[], ): VerificationResultLikeItem[] | undefined { if (!result) return undefined; const direct = result[fieldName]; if (Array.isArray(direct) && direct.length > 0) return direct; if (aliases) { for (const alias of aliases) { const found = result[alias]; if (Array.isArray(found) && found.length > 0) return found; } } return undefined; }