(
    parts: Sequence[Union[str, int]]
)
return None
Format a validation location from FastAPI into an ErrorSource.
Format a validation location from FastAPI into an ErrorSource.
Format a validation location from FastAPI into an ErrorSource .
def _format_validation_source(
    parts: Sequence[Union[str, int]]
) -> Optional[ErrorSource]:
    """Format a validation location from FastAPI into an ErrorSource."""
    try:
        if parts[0] == "body":
            # ["body", "field"] > { "pointer": "/field" }
            return ErrorSource(pointer=f"/{'/'.join(str(p) for p in parts[1::])}")
        elif parts[0] == "query":
            # ["query", "param"] > { parameter: "param" }
            return ErrorSource(parameter=str(parts[1]))
        elif parts[0] == "header":
            # ["header", "name"] > { header: "name" }
            return ErrorSource(header=str(parts[1]))
    except KeyError:
        pass

    return None
def _format_validation_source ( parts : Sequence [ Union [ str , int ] ] ) -> Optional [ ErrorSource ] : try : if parts [ 0 ] == "body" : # ["body", "field"] > { "pointer": "/field" } return ErrorSource ( pointer = f"/{'/'.join(str(p) for p in parts[1::])}" ) elif parts [ 0 ] == "query" : # ["query", "param"] > { parameter: "param" } return ErrorSource ( parameter = str ( parts [ 1 ] ) ) elif parts [ 0 ] == "header" : # ["header", "name"] > { header: "name" } return ErrorSource ( header = str ( parts [ 1 ] ) ) except KeyError : pass return None