KI-AGENT: Beleg-Relationswerte vor dem Speichern normalisieren
This commit is contained in:
@@ -936,7 +936,16 @@ export default async function resourceRoutes(server: FastifyInstance) {
|
||||
|
||||
const normalizeDate = (val: any) => { const d = new Date(val); return isNaN(d.getTime()) ? null : d; }
|
||||
Object.keys(createData).forEach((key) => {
|
||||
if (key.toLowerCase().includes("date") && key !== "deliveryDateType") createData[key] = normalizeDate(createData[key])
|
||||
const value = createData[key]
|
||||
const shouldNormalize =
|
||||
isDateLikeField(key) &&
|
||||
value !== null &&
|
||||
value !== undefined &&
|
||||
(typeof value === "string" || typeof value === "number" || value instanceof Date)
|
||||
|
||||
if (shouldNormalize) {
|
||||
createData[key] = normalizeDate(value)
|
||||
}
|
||||
})
|
||||
|
||||
const [created] = await server.db.insert(table).values(createData).returning()
|
||||
|
||||
Reference in New Issue
Block a user