rumine-api-wrapper/db/schemas/UUIDSchema.py

14 lines
342 B
Python
Raw Normal View History

2024-03-07 14:06:53 +01:00
from pydantic import BaseModel, field_validator
import uuid
class UUIDSchema(BaseModel):
uuid: str
@field_validator('uuid')
def validate_uuid(cls, value):
try:
uuid_obj = uuid.UUID(value)
except ValueError as e:
raise ValueError("Invalid UUID format") from e
return str(uuid_obj)