Skip to content

move Search field validators outside model #174

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

Merged
merged 2 commits into from
Mar 20, 2025

Conversation

vincentsarago
Copy link
Member

This PR does:

  • move bbox and datetime validator outside the Search class (so we can re-use them in https://github.com/stac-utils/stac-fastapi/blob/main/stac_fastapi/types/stac_fastapi/types/search.py#L150-L210)

  • remove Search private attribute (_start/_end datetime) in order to do ☝️. The start_datetime and end_datetime properties are still available, but now we will dynamically process them (parse datetime and return the value). This is a small performance drawback.... but I don't think many users use those properties (we could make them cached_properties in the future, or use lru_cache to cache the datetime parsing

@vincentsarago vincentsarago requested a review from gadomski March 18, 2025 21:12
"Maximum elevation must greater than minimum elevation"
)
else:
raise ValueError("Bounding box must have 4 or 6 coordinates")
Copy link
Member Author

Choose a reason for hiding this comment

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

This will not be called normally because pydantic will already check if the inputs are tuple of 4 or 6 values. But I think if we want to re-use the validator outside pydantic model (e.g in stac-fastapi) it will be useful

for v in values
],
)
return dates
Copy link
Member Author

Choose a reason for hiding this comment

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

extract the parsing function in order to re-use it and get rid of https://github.com/stac-utils/stac-fastapi/blob/main/stac_fastapi/types/stac_fastapi/types/rfc3339.py 🙈

@vincentsarago vincentsarago merged commit 962e814 into main Mar 20, 2025
6 checks passed
@vincentsarago vincentsarago deleted the feature/validator-reutilization branch March 20, 2025 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants