29 lines
632 B
Python
29 lines
632 B
Python
from typing import Optional
|
|
from uuid import UUID
|
|
from pydantic import BaseModel, validator
|
|
|
|
|
|
class AccessToken(BaseModel):
|
|
|
|
accessToken: Optional[str] = None
|
|
userUUID: Optional[str] = None
|
|
|
|
@validator("userUUID", pre=True)
|
|
def validate_uuid(cls, v):
|
|
"""Convert UUID to string during validation."""
|
|
if isinstance(v, UUID):
|
|
return str(v)
|
|
return v
|
|
|
|
def to_list(self):
|
|
"""Convert to list for Redis storage."""
|
|
return [self.accessToken, self.userUUID]
|
|
|
|
@property
|
|
def count(self):
|
|
return 2
|
|
|
|
@property
|
|
def delimiter(self):
|
|
return "*"
|