건축물 데이터 검증 소스 수정

This commit is contained in:
leedj312
2025-08-18 14:53:00 +09:00
parent 6b88a8584b
commit 9c19f239c2
10 changed files with 92 additions and 52 deletions
+25 -1
View File
@@ -272,4 +272,28 @@ export const formatYyyymmdd = (val: string | undefined) => {
}
const m = moment(val);
return m.isValid() ? m.format("YYYY-MM-DD") : val;
};
};
/**
* 문자열 숫자(콤마 포함 가능)를 반올림 처리해 반환.
* 숫자가 아닌 경우(예: "확인불가")는 원래 값을 그대로 반환.
*
* @param value 입력 문자열
* @param digits 소수점 자릿수 (기본 0 = 정수 반올림)
*/
export const formatArchArea =(value: string, digits: number=0 ) => {
// "확인불가" 등 숫자 아님 → 그대로 반환
const cleaned = value.replace(/,/g, "");
const num = parseFloat(cleaned);
if (isNaN(num)) {
return value;
}
// 반올림 (digits 자릿수까지)
const rounded = num.toFixed(digits);
// 다시 천 단위 콤마 찍어서 반환
return Number(rounded).toLocaleString();
}