Skip to content

Verbose validation error is difficult to understand #93

@svaccari

Description

@svaccari

Hi, I was validating this Polygon that has a linear rings with different start/end coordinates:

{
    "type": "Feature",
    "geometry": {
        "type": "Polygon",
        "coordinates": [
            [
                [-55.9947406591177, -9.26104045526505],
                [-55.9976752102375, -9.266589696568962],
                [-56.00200328975916, -9.264041751931352],
                [-55.99899921566248, -9.257935213034594],
                [-55.99477406591177, -9.26103945526505],
            ]
        ],
    },
}

And I received the following message:

18 validation errors for Feature
geometry -> type
  unexpected value; permitted: 'Point' (type=value_error.const; given=Polygon; permitted=['Point'])
geometry -> coordinates
  wrong tuple length 1, expected 2 (type=value_error.tuple.length; actual_length=1; expected_length=2)
geometry -> coordinates
  wrong tuple length 1, expected 3 (type=value_error.tuple.length; actual_length=1; expected_length=3)
geometry -> type
  unexpected value; permitted: 'MultiPoint' (type=value_error.const; given=Polygon; permitted=['MultiPoint'])
geometry -> coordinates -> 0
  wrong tuple length 5, expected 2 (type=value_error.tuple.length; actual_length=5; expected_length=2)
geometry -> coordinates -> 0
  wrong tuple length 5, expected 3 (type=value_error.tuple.length; actual_length=5; expected_length=3)
geometry -> type
  unexpected value; permitted: 'LineString' (type=value_error.const; given=Polygon; permitted=['LineString'])
geometry -> coordinates
  ensure this value has at least 2 items (type=value_error.list.min_items; limit_value=2)
geometry -> type
  unexpected value; permitted: 'MultiLineString' (type=value_error.const; given=Polygon; permitted=['MultiLineString'])
geometry -> coordinates
  All linear rings have the same start and end coordinates (type=value_error)
geometry -> type
  unexpected value; permitted: 'MultiPolygon' (type=value_error.const; given=Polygon; permitted=['MultiPolygon'])
geometry -> coordinates -> 0 -> 0
  ensure this value has at least 4 items (type=value_error.list.min_items; limit_value=4)
geometry -> coordinates -> 0 -> 1
  ensure this value has at least 4 items (type=value_error.list.min_items; limit_value=4)
geometry -> coordinates -> 0 -> 2
  ensure this value has at least 4 items (type=value_error.list.min_items; limit_value=4)
geometry -> coordinates -> 0 -> 3
  ensure this value has at least 4 items (type=value_error.list.min_items; limit_value=4)
geometry -> coordinates -> 0 -> 4
  ensure this value has at least 4 items (type=value_error.list.min_items; limit_value=4)
geometry -> type
  unexpected value; permitted: 'GeometryCollection' (type=value_error.const; given=Polygon; permitted=['GeometryCollection'])
geometry -> geometries
  field required (type=value_error.missing)

However this does not happen if Feature is omitted:

{
    "type": "Polygon",
    "coordinates": [
        [
            [-55.9947406591177, -9.26104045526505],
            [-55.9976752102375, -9.266589696568962],
            [-56.00200328975916, -9.264041751931352],
            [-55.99899921566248, -9.257935213034594],
            [-55.99477406591177, -9.26103945526505],
        ]
    ],
}

Result:

1 validation error for Polygon
coordinates
  All linear rings have the same start and end coordinates (type=value_error)

Can you look into that?
Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions