dbmsv4 init...4

This commit is contained in:
최준흠 2026-01-06 13:36:59 +09:00
parent 298e498cf5
commit 2249919861

View File

@ -210,35 +210,29 @@ abstract class CommonForm
} }
} catch (\TypeError $e) { } catch (\TypeError $e) {
// TypeError(예: trim(null) 등) 발생 시 범인(field) 찾기 시도 // TypeError(예: trim(null) 등) 발생 시 범인(field) 찾기 시도
$culpritField = "알 수 없음"; $nullFields = [];
$culpritValue = "null"; $findNulls = function ($data, $path = '') use (&$findNulls, &$nullFields) {
foreach ($data as $k => $v) {
foreach ($dynamicRules as $f => $r) { $curr = $path ? "{$path}.{$k}" : $k;
if (str_contains($r['rules'], 'trim')) { if (is_array($v)) {
// 중첩 필드(.*)와 일반 필드 구분하여 null 체크 $findNulls($v, $curr);
if (str_contains($f, '.*')) { } elseif ($v === null) {
$parentKey = str_replace('.*', '', $f); $nullFields[] = $curr;
if (isset($formDatas[$parentKey]) && is_array($formDatas[$parentKey])) {
foreach ($formDatas[$parentKey] as $k => $v) {
if ($v === null) {
$culpritField = "{$parentKey}.{$k} ({$r['label']})";
break 2;
}
}
}
} else {
if (!isset($formDatas[$f]) || $formDatas[$f] === null) {
$culpritField = "{$f} ({$r['label']})";
break;
}
} }
} }
} };
$findNulls($formDatas);
$culpritInfo = count($nullFields) > 0 ? implode(', ', $nullFields) : "데이터 내 null 없음 (시스템 내 필터 등에 의해 발생 가능성)";
$errorMsg = $e->getMessage(); $errorMsg = $e->getMessage();
// "trim(): Argument #1 ($string) must be of type string, null given" 문구에서 Argument #1을 필드명으로 교체 // 상세 정보 포함
$errorMsg = str_replace("Argument #1 (\$string)", "데이터(필드: {$culpritField}, 값: {$culpritValue})", $errorMsg); $debugInfo = "\n--- [상세 디버깅 정보] ---\n";
throw new RuntimeException("검증 도중 타입 오류 발생: " . $errorMsg); $debugInfo .= "범인 의심 필드(null값): " . $culpritInfo . "\n";
$debugInfo .= "전송된 데이터(전체): " . json_encode($formDatas, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) . "\n";
$debugInfo .= "규칙 정보: " . json_encode($dynamicRules, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) . "\n";
throw new RuntimeException("검증 도중 타입 오류 발생: {$errorMsg}{$debugInfo}");
} }
// 검증 성공 시 추가 로직 없이 종료 // 검증 성공 시 추가 로직 없이 종료