-
Notifications
You must be signed in to change notification settings - Fork 37
Verbose validation error is difficult to understand #93
New issue
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
Comments
@svaccari the first edit: I think we should use https://github.com/developmentseed/geojson-pydantic/blob/main/geojson_pydantic/geometries.py#L246 in https://github.com/developmentseed/geojson-pydantic/blob/main/geojson_pydantic/features.py#L29-L34 |
Depends on #94 (types as Literals). But this is 90% solved by the following: from typing_extensions import Annotated
...
Geometry = Annotated[
Union[Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon],
Field(discriminator="type"),
] The error would then just be:
I haven't quite figured out getting rid of the |
Took a bunch of iterations, but got it: class Feature(GenericModel, Generic[Geom, Props]):
...
geometry: Annotated[Union[Geom, None], Field(..., discriminator="type")] And then you get
Edit: Updated to be required field. |
Tweak Geometry to include GeometryCollection. Fixes: #93
Hi, I was validating this Polygon that has a linear rings with different start/end coordinates:
And I received the following message:
However this does not happen if
Feature
is omitted:Result:
Can you look into that?
Thanks.
The text was updated successfully, but these errors were encountered: