79739884

Date: 2025-08-19 12:25:00
Score: 0.5
Natty:
Report link

In the Pydantic documentation, the example for customizing the schema completely with the __get_pydantic_core_schema function override uses core_schema.no_info_plain_validator_function.

    def __get_pydantic_core_schema__(
        self, source: type[Any], handler: GetCoreSchemaHandler
    ) -> core_schema.CoreSchema:
        ...
        return core_schema.no_info_plain_validator_function(validate)

In your code:

    @classmethod
    def __get_pydantic_core_schema__(cls, source_type: Any, handler):

        cls._schema = _CustomModel._make_schema()

        fn = core_schema.no_info_plain_validator_function(
            function=cls._validate,
            schema=cls._schema,
        )

        return fn
Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: r_2009