Skip to content

Commit

Permalink
🐛 Handle pydantic root validation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
perdy committed Jan 5, 2025
1 parent 0fb1f27 commit de90e16
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion flama/schemas/_libs/pydantic/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ def validate(
try:
return schema_cls(**values).model_dump(exclude_unset=partial)
except pydantic.ValidationError as errors:
raise SchemaValidationError(errors={str(error["loc"][0]): error for error in errors.errors()})
raise SchemaValidationError(
errors={
".".join(str(x) for x in error.get("loc", [])): error for error in errors.errors(include_url=False)
}
)

def load(self, schema: t.Union[Schema, type[Schema]], value: dict[str, t.Any]) -> Schema:
schema_cls = self.unique_schema(schema)
Expand Down

0 comments on commit de90e16

Please sign in to comment.