Spaces:
Paused
Paused
Update app/db/schemas.py
Browse files- app/db/schemas.py +19 -0
app/db/schemas.py
CHANGED
|
@@ -24,6 +24,25 @@ class UserInDB(UserBase):
|
|
| 24 |
class Config:
|
| 25 |
from_attributes = True
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
@validates('email')
|
| 28 |
def validate_email(self, key, email):
|
| 29 |
if not re.match(r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$', email):
|
|
|
|
| 24 |
class Config:
|
| 25 |
from_attributes = True
|
| 26 |
|
| 27 |
+
class ProductBase(BaseModel):
|
| 28 |
+
name: str
|
| 29 |
+
description: str
|
| 30 |
+
price: float
|
| 31 |
+
category: str
|
| 32 |
+
inventory_count: int
|
| 33 |
+
seller_id: int
|
| 34 |
+
|
| 35 |
+
class ProductCreate(ProductBase):
|
| 36 |
+
pass
|
| 37 |
+
|
| 38 |
+
class ProductInDB(ProductBase):
|
| 39 |
+
id: int
|
| 40 |
+
created_at: datetime
|
| 41 |
+
updated_at: Optional[datetime] = None
|
| 42 |
+
|
| 43 |
+
class Config:
|
| 44 |
+
from_attributes = True
|
| 45 |
+
|
| 46 |
@validates('email')
|
| 47 |
def validate_email(self, key, email):
|
| 48 |
if not re.match(r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$', email):
|