Skip to content

Commit

Permalink
Fix device created empty string (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck authored Dec 18, 2021
1 parent 6bc8c3a commit 4ffa1a6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/tailscale/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ class Device(BaseModel):
advertised_routes: List[str] = Field(alias="advertisedRoutes", default_factory=list)
client_connectivity: ClientConnectivity = Field(alias="clientConnectivity")

@validator("created", pre=True)
@classmethod
def empty_as_none(cls, data: str | None) -> str | None: # noqa: F841
"""Convert an emtpty string to None.
Args:
data: String to convert.
Returns:
String or none if string is empty.
"""
if not data:
return None
return data


class Devices(BaseModel):
"""Object holding Tailscale device information."""
Expand Down

0 comments on commit 4ffa1a6

Please sign in to comment.