(data: RowData, schema: TableSchema)
| 324 | * from `data` are skipped — it never invents a missing-required-field error). |
| 325 | */ |
| 326 | export function coerceRowValues(data: RowData, schema: TableSchema): void { |
| 327 | for (const column of schema.columns) { |
| 328 | const key = getColumnId(column) |
| 329 | const value = data[key] |
| 330 | if (value === null || value === undefined) continue |
| 331 | |
| 332 | const coerced = coerceValueToColumnType(value, column.type) |
| 333 | if (coerced.ok) { |
| 334 | data[key] = coerced.value |
| 335 | } else if (!column.required) { |
| 336 | data[key] = null |
| 337 | } |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | /** |
| 342 | * Coerces a full row toward its schema **in place** (see {@link coerceRowValues}) |
no test coverage detected