Skip to content

Commit

Permalink
Merge pull request #580 from wri/fix-version-metadata-bug
Browse files Browse the repository at this point in the history
Fix version metadata bug
  • Loading branch information
solomon-negusse authored Aug 28, 2024
2 parents 7f2be86 + 6f89964 commit 9cadb7c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/models/pydantic/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Any, List, Optional, Union
from uuid import UUID

from fastapi import HTTPException
from pydantic import Field, validator, BaseModel
from pydantic.utils import GetterDict

Expand Down Expand Up @@ -176,10 +177,12 @@ class VersionMetadataWithParentResponse(Response):


def _date_validator(date_str):
if isinstance(date_str, date):
if isinstance(date_str, date) or date_str is None:
return date_str

try:
return datetime.strptime(date_str, "%Y-%m-%d").date()
except (ValueError, TypeError):
return None
raise HTTPException(
status_code=422, detail="Date needs to be of the format YYYY-MM-DD"
)

0 comments on commit 9cadb7c

Please sign in to comment.