<reponame>ElPapi42/test-api
from bson.objectid import ObjectId, InvalidId


class PydanticObjectId(str):
    @classmethod
    def __get_validators__(cls):
        yield cls.validate

    @classmethod
    def validate(cls, v):
        try:
            ObjectId(str(v))
        except InvalidId:
            raise TypeError('invalid ObjectId')
        return str(v)

from bson.objectid import ObjectId, InvalidId


class PydanticObjectId(str):
    @classmethod
    def __get_validators__(cls):
        yield cls.validate

    @classmethod
    def validate(cls, v):
        try:
            ObjectId(str(v))
        except InvalidId:
            raise TypeError('invalid ObjectId')
        return str(v)