Spaces:
Sleeping
Sleeping
Download build/lib/models/user.py from hashir-qt/tasklert-api: direct link, hf CLI and curl.
- Browser
- Download file 1.23 kB
-
https://huggingface.co/spaces/hashir-qt/tasklert-api/resolve/main/build/lib/models/user.py
- Command line
-
hf download hf://spaces/hashir-qt/tasklert-api/build/lib/models/user.py
-
curl -L -o user.py https://huggingface.co/spaces/hashir-qt/tasklert-api/resolve/main/build/lib/models/user.py
1.23 kB
| from datetime import datetime, timezone | |
| from pydantic import field_validator | |
| from sqlmodel import SQLModel, Field | |
| class User(SQLModel, table=True): | |
| id: int | None = Field(default=None, primary_key=True) | |
| email: str = Field(index=True, unique=True) | |
| name: str = Field(index=True) | |
| hashed_password: str | |
| is_active: bool = True | |
| created_at: datetime = Field( | |
| default_factory=lambda: datetime.now(timezone.utc) | |
| ) | |
| updated_at: datetime = Field( | |
| default_factory=lambda: datetime.now(timezone.utc) | |
| ) | |
| class UserRegister(SQLModel): | |
| email: str | |
| password: str | |
| name: str | |
| def password_min_length(cls, v: str) -> str: | |
| if len(v) < 8: | |
| raise ValueError("Password must be at least 8 characters") | |
| return v | |
| def name_length(cls, v: str) -> str: | |
| if not v or len(v) > 100: | |
| raise ValueError("Name must be 1-100 characters") | |
| return v | |
| class UserLogin(SQLModel): | |
| email: str | |
| password: str | |
| class UserRead(SQLModel): | |
| id: int | |
| email: str | |
| name: str | |
| is_active: bool | |
| created_at: datetime | |
| updated_at: datetime | |