Skip to content

Commit

Permalink
Add inline comments for HostPolicy validator
Browse files Browse the repository at this point in the history
  • Loading branch information
pederhan committed May 5, 2024
1 parent fdf42cc commit 38f7353
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mreg_cli/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,10 @@ def validate_created_at(cls, value: Any) -> datetime:
# Fast path for str (most likely input type)
if isinstance(value, str):
return datetime.fromisoformat(value)
# Re-validating model (field is already a datetime object)
elif isinstance(value, datetime):
return value
# Date object is also valid input (parity with API)
elif isinstance(value, date):
return datetime.combine(value, datetime.min.time())
return value # let pydantic throw the ValidationError
Expand Down

0 comments on commit 38f7353

Please sign in to comment.