Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.
This repository was archived by the owner on Sep 9, 2026. It is now read-only.

[pydantic v2] Validation with default value is not working #1787

Closed

Description

@samsja

Context

 class MyDocument(BaseDoc):
        caption: TextDoc



MyDocument(caption='A tiger in the jungle')

this will fail bc I did not find a way yet to override pydantic validation for BaseDoc

many test are skipped because of this example:

@pytest.mark.skipif(

Many of tests/predefined_document failed for this reason. (search for skipif inside the folder to see which one).

Hint: to solve this one we need to highjack pydantic validation to convert the single value into a dict. We are already doing this with pydantic v1 but since pydantic v2 validation has partially been moved to the pydantic_core package it is less obvious how to do it.

Obviously, in python we can always make it work, the question is how to make it work so that it will still be aligned with pydantic guardrails regarding validation

Activity

  1. converted this from a draft issue on Sep 15, 2023
  2. linked a pull request that will close this issuefix: wip add default value to TextDoc #1798on Sep 19, 2023
  3. linked a pull request that will close this issuefix: validate before #1806on Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions