update empty string to null
This commit is contained in:
@@ -92,7 +92,22 @@ function parseIntString (s: string | string[] | undefined) :number | null {
|
||||
return regex.test(s) ? Number(s) : null
|
||||
}
|
||||
|
||||
// Функция для преобразования пустых строк в null
|
||||
function convertEmptyStringsToNull<T extends Record<string, unknown>>(obj: T): T {
|
||||
const result = { ...obj } as Record<string, unknown>
|
||||
|
||||
Object.keys(result).forEach(key => {
|
||||
if (result[key] === '') {
|
||||
result[key] = null
|
||||
}
|
||||
})
|
||||
|
||||
return result as T
|
||||
}
|
||||
|
||||
|
||||
export {
|
||||
isDirty,
|
||||
parseIntString
|
||||
parseIntString,
|
||||
convertEmptyStringsToNull
|
||||
}
|
||||
Reference in New Issue
Block a user