The last string segment of a validation error's `loc`, e.g. the field.
(loc: unknown)
| 20 | |
| 21 | /** The last string segment of a validation error's `loc`, e.g. the field. */ |
| 22 | function getValidationField(loc: unknown): string | null { |
| 23 | if (!Array.isArray(loc)) return null; |
| 24 | const field = [...loc].reverse().find((part) => typeof part === "string"); |
| 25 | return typeof field === "string" && field ? field : null; |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Join the `msg` fields of a FastAPI/Pydantic validation `detail` array |
no outgoing calls
no test coverage detected