-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.py
56 lines (45 loc) · 1.09 KB
/
schema.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Python
from uuid import UUID
from datetime import datetime, date
from typing import Optional
# Pydantic
from pydantic import BaseModel
from pydantic import EmailStr
from pydantic import Field
class UserBase(BaseModel):
user_id: UUID = Field(...)
class Config:
orm_mode = True
class User(BaseModel):
first_name: str = Field(
...,
min_length=1,
max_length=50
)
last_name: str = Field(
...,
min_length=1,
max_length=50
)
birth_date: Optional[date] = Field(default=None)
class Config:
orm_mode = True
class UserRegister(UserBase, User):
email: EmailStr = Field(...)
password: str = Field(
...,
min_length=8,
max_length=64
)
class Tweet(BaseModel):
content: str = Field(
...,
max_length=256,
min_length=1)
created_at: datetime = Field(default=datetime.now())
updated_at: Optional[datetime] = Field(default=None)
user_id: UUID = Field(...)
class Config:
orm_mode = True
class TweetPost(Tweet):
tweet_id: UUID = Field(...)