We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I think it would be great if it where possible to map pydantic validation errors to proper fhir locations for `OperationOutcome' https://hl7.org/fhir/STU3/operationoutcome.html#loc
Do you have some thoughts/guidance on that. I might try to implement something like that.
The text was updated successfully, but these errors were encountered:
You are more than welcome to do try and share your thoughts
Sorry, something went wrong.
I am currently using this:
def pydantic_loc_to_xpath(location_path): result = "" for loc in location_path: if loc == "__root__": continue if isinstance(loc, int): result += f"[{loc}]" else: result += f"/f:{loc}" return result def pydantic_error_to_operation_issue(error): loc = pydantic_loc_to_xpath(error["loc"]) code = "required" if error["type"] == "value_error.missing" else "invalid" return { "severity": "error", "code": code, "location": [loc], "diagnostics": error["msg"], }
It seems to work fine and generates response ala:
{ "severity": "error", "code": "required", "diagnostics": "field required", "location": ["/f:fhirVersion"], }, { "severity": "error", "code": "invalid", "diagnostics": "value is not a valid integer", "location": ["/f:contact[1]/f:telecom[0]/f:rank"], }, { "severity": "error", "code": "invalid", "diagnostics": "invalid datetime format", "location": ["/f:date"], },
Granted, it might not be perfect but it already looks rather nice.
No branches or pull requests
Description
I think it would be great if it where possible to map pydantic validation errors to proper fhir locations for `OperationOutcome' https://hl7.org/fhir/STU3/operationoutcome.html#loc
Do you have some thoughts/guidance on that. I might try to implement something like that.
The text was updated successfully, but these errors were encountered: