Skip to content

Commit

Permalink
distinguish between datetime, date and partial date
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinscholl committed Feb 21, 2024
1 parent dedd37a commit 1e07652
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions mex/common/models/resource.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Annotated, Literal
from datetime import date, datetime
from typing import Annotated, Literal, Union

from pydantic import Field

Expand All @@ -24,7 +25,7 @@
ResourceTypeGeneral,
Text,
Theme,
Timestamp,
YearMonth,
)


Expand Down Expand Up @@ -57,7 +58,7 @@ class BaseResource(BaseModel):
]
contributingUnit: list[OrganizationalUnitID] = []
contributor: list[PersonID] = []
created: Timestamp | None = None
created: Union[date, datetime, YearMonth, None] = None
creator: list[PersonID] = []
description: list[Text] = []
distribution: list[DistributionID] = []
Expand Down Expand Up @@ -86,7 +87,7 @@ class BaseResource(BaseModel):
] = []
method: list[Text] = []
methodDescription: list[Text] = []
modified: Timestamp | None = None
modified: Union[date, datetime, YearMonth, None] = None
publication: list[Link] = []
publisher: list[OrganizationID] = []
qualityInformation: list[Text] = []
Expand All @@ -110,9 +111,12 @@ class BaseResource(BaseModel):
),
]
] = []
temporal: (
Timestamp
| Annotated[
temporal: Union[
None,
date,
datetime,
YearMonth,
Annotated[
str,
Field(
examples=[
Expand All @@ -122,9 +126,8 @@ class BaseResource(BaseModel):
"1998-2008",
]
),
]
| None
) = None
],
] = None
theme: Annotated[
list[Annotated[Theme, Field(examples=["https://mex.rki.de/item/theme-1"])]],
Field(min_length=1),
Expand Down

0 comments on commit 1e07652

Please sign in to comment.