Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added pydantic validation support to ObjectId #120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BlackIsBlack
Copy link

@BlackIsBlack BlackIsBlack commented Jan 13, 2023

Implemented __get_validators__ from pydantic to allow for type hinting within a class for an ObjectId.

Example

from pydantic import BaseModel
from bson import ObjectId

class Example(BaseModel):
    id: ObjectId

example = Example(id=ObjectId())

@BlackIsBlack BlackIsBlack marked this pull request as ready for review January 13, 2023 05:20
@BlackIsBlack BlackIsBlack marked this pull request as draft February 8, 2023 23:43
@BlackIsBlack BlackIsBlack marked this pull request as ready for review February 8, 2023 23:43
@Kludex
Copy link
Member

Kludex commented Jul 3, 2023

Nice! Thanks for this. 👍

V2 now has the __get_pydantic_core_schema__.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants