fix: 完善动态错误指引与发票日期校验(09-05-error-explainability-payment-readiness)
这个提交包含在:
+2
-10
@@ -1,4 +1,5 @@
|
||||
const { z } = require("zod");
|
||||
const { buildBusinessValidationError } = require("../utils/businessValidationError");
|
||||
|
||||
const { AppError } = require("../utils/AppError");
|
||||
const { buildAuditLogData } = require("../utils/audit");
|
||||
@@ -11,19 +12,10 @@ const NOTIFICATION_PREFERENCES_SCHEMA = z
|
||||
})
|
||||
.strict();
|
||||
|
||||
function buildValidationError(details) {
|
||||
return new AppError({
|
||||
code: "VALID_001",
|
||||
message: "参数校验失败",
|
||||
statusCode: 400,
|
||||
details,
|
||||
});
|
||||
}
|
||||
|
||||
function parseNotificationPreferences(body) {
|
||||
const parsed = NOTIFICATION_PREFERENCES_SCHEMA.safeParse(body ?? {});
|
||||
if (!parsed.success) {
|
||||
throw buildValidationError(parsed.error.flatten());
|
||||
throw buildBusinessValidationError("profile.notification_preferences_invalid", parsed.error.flatten());
|
||||
}
|
||||
|
||||
return parsed.data;
|
||||
|
||||
在新工单中引用
屏蔽一个用户