Skip to content

Commit f586036

Browse files
committed
fix: migrate GeometryValidatorMixin to Pydantic V2 field_validator
The V1-style @validator decorator is deprecated in Pydantic 2.x and scheduled for removal in V3. Migrates GeometryValidatorMixin's geometry validator to the V2 @field_validator API, adding the explicit @classmethod that V2 requires (V1 handled this implicitly). Validator logic is unchanged. Verified: no PydanticDeprecatedSince20 warning fires for this validator anymore, and the existing test suite still passes (5 passed). Part of incremental migration for #256 - other validators/Field(example=) usages in this file still need converting in follow-up PRs. Signed-off-by: Brian Bergstrom <dulcetberg@gmail.com>
1 parent e69a6e3 commit f586036

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎src/validation/models.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# Third party imports
2525
from geojson_pydantic import Feature, FeatureCollection, MultiPolygon, Polygon
2626
from pydantic import BaseModel as PydanticModel
27-
from pydantic import Field, validator
27+
from pydantic import Field, field_validator, validator
2828

2929
# Reader imports
3030
from src.config import (
@@ -120,7 +120,8 @@ class Filters(BaseModel):
120120

121121

122122
class GeometryValidatorMixin:
123-
@validator("geometry")
123+
@field_validator("geometry")
124+
@classmethod
124125
def validate_geometry(cls, value):
125126
"""Validates geometry"""
126127
if value:

0 commit comments

Comments
 (0)