import uuid from typing import Annotated from pydantic import PlainValidator, WithJsonSchema def _validate_global_participant_id(value: str) -> str: try: uuid.UUID(value, version=4) except ValueError as exc: raise ValueError("value is not a valid UUID4") from exc return value GlobalParticipantId = Annotated[ str, PlainValidator(_validate_global_participant_id), WithJsonSchema({"type": "string", "format": "uuid4"}), ]