(inputFormatValue: unknown)
| 217 | * @returns Array of validated input format fields |
| 218 | */ |
| 219 | export function normalizeInputFormatValue(inputFormatValue: unknown): InputFormatField[] { |
| 220 | // Handle null, undefined, and empty arrays |
| 221 | if ( |
| 222 | inputFormatValue === null || |
| 223 | inputFormatValue === undefined || |
| 224 | (Array.isArray(inputFormatValue) && inputFormatValue.length === 0) |
| 225 | ) { |
| 226 | return [] |
| 227 | } |
| 228 | |
| 229 | // Handle non-array values |
| 230 | if (!Array.isArray(inputFormatValue)) { |
| 231 | return [] |
| 232 | } |
| 233 | |
| 234 | // Filter valid fields |
| 235 | return inputFormatValue.filter( |
| 236 | (field): field is InputFormatField => |
| 237 | field && |
| 238 | typeof field === 'object' && |
| 239 | typeof field.name === 'string' && |
| 240 | field.name.trim() !== '' |
| 241 | ) |
| 242 | } |
no outgoing calls
no test coverage detected