Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation for number of datetimes in Temporal.interval #17

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/edr_pydantic/extent.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from typing import Annotated
from typing import List
from typing import Optional
from typing import Union

from annotated_types import Len
from pydantic import AwareDatetime

from .base_model import EdrBaseModel
Expand All @@ -13,8 +15,7 @@ class Spatial(EdrBaseModel):


class Temporal(EdrBaseModel):
# TODO: Validate this list has two items (C.7. Temporal Object)
interval: List[List[AwareDatetime]]
interval: List[Annotated[List[AwareDatetime], Len(min_length=2, max_length=2)]]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: add some test cases to confirm that validation fails when lists are provided with len(...) != 2.

# TODO: Validate this is a list of ISO 8601 single time, ISO 8601 time duration or ISO 8601 interval
values: List[str]
trs: str
Expand Down
Loading