-api เส้น register

-เครื่องมือต่างๆ (ไม่สมบูร)
This commit is contained in:
x2Skyz
2025-11-21 12:09:43 +07:00
parent 4cb135d251
commit f8344e7afc
13 changed files with 561 additions and 139 deletions

View File

@@ -0,0 +1,25 @@
import { sendError } from './response.js';
export const validateSave = (value, columnName) => {
// เช็คว่าค่าเป็น null, undefined หรือ empty string
if (value === undefined || value === null || value === '') {
// สร้างก้อน data ที่จะบอกว่า column ไหนหายไป
// ตามโจทย์: data: { "email": "ไม่พบข้อมูล" }
const errorDetail = {};
errorDetail[columnName] = "ไม่พบข้อมูล";
// เรียก sendError ใส่ message และ errorDetail ลงไปใน parameter ตัวที่ 4
sendError(
'ข้อมูลพารามิเตอร์ ไม่ถูกต้อง', // thMsg
'Invalid Parameter', // enMsg
400, // code
errorDetail // data
);
// ปาลูกระเบิดออกไปให้ Controller รับ
// throw errorObj;
}
return value;
}