Skip to content

Commit 7c2482a

Browse files
authored
Merge pull request #114 from tesselo/fix-item-bbox-validation
Fix item bbox field validation
2 parents 9a5a653 + 582f9c6 commit 7c2482a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

stac_pydantic/item.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Dict, List, Optional, Union
33

44
from geojson_pydantic.features import Feature, FeatureCollection
5-
from pydantic import AnyUrl, Field, constr, validator
5+
from pydantic import AnyUrl, Field, constr, root_validator, validator
66
from pydantic.datetime_parse import parse_datetime
77

88
from stac_pydantic.api.extensions.context import ContextExtension
@@ -56,11 +56,11 @@ def to_dict(self, **kwargs):
5656
def to_json(self, **kwargs):
5757
return self.json(by_alias=True, exclude_unset=True, **kwargs)
5858

59-
@validator("bbox")
60-
def validate_bbox(cls, v, values):
61-
if v is None and not values.get("geometry"):
59+
@root_validator(pre=True)
60+
def validate_bbox(cls, values):
61+
if values.get("geometry") and values.get("bbox") is None:
6262
raise ValueError("bbox is required if geometry is not null")
63-
return v
63+
return values
6464

6565

6666
class ItemCollection(FeatureCollection):

0 commit comments

Comments
 (0)