14 lines
342 B
Python
14 lines
342 B
Python
|
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)
|