Normalizes a validation result to a list of validation errors.
(error: T | readonly T[])
| 374 | |
| 375 | /** Normalizes a validation result to a list of validation errors. */ |
| 376 | function normalizeErrors<T extends ValidationResult>(error: T | readonly T[]): readonly T[] { |
| 377 | if (error === undefined) { |
| 378 | return []; |
| 379 | } |
| 380 | |
| 381 | if (isArray(error)) { |
| 382 | return error as readonly T[]; |
| 383 | } |
| 384 | |
| 385 | return [error as T]; |
| 386 | } |
| 387 | |
| 388 | /** |
| 389 | * Sets the given field on the given error(s) if it does not already have a field. |
no test coverage detected
searching dependent graphs…