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

Configure behavior for extra fields at runtime / validation time #9278

Open
4 of 13 tasks
lesinigo opened this issue Apr 18, 2024 · 1 comment
Open
4 of 13 tasks

Configure behavior for extra fields at runtime / validation time #9278

lesinigo opened this issue Apr 18, 2024 · 1 comment
Labels
feature request V3 Under consideration for V3

Comments

@lesinigo
Copy link

Initial Checks

  • I have searched Google & GitHub for similar requests and couldn't find anything
  • I have read and followed the docs and still think this feature is missing

Description

I would like to change the extra configuration of a model dynamically at runtime / validation time.

Example of hypothetical implementation:

SomeModel(BaseModel):
    my_field: int
    model_config = ConfigDict(extra="allow")

data = SomeModel.model_validate(
    {"myfield": 1, "extra field": 2},
    extra="forbid"  # override model config and forbid extra fields just this time
)

Affected Components

@sydney-runkle
Copy link
Member

I wonder if this falls in the V3 bucket, I think we might want to reconsider the relationship between config settings and runtime options...

@sydney-runkle sydney-runkle added the V3 Under consideration for V3 label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request V3 Under consideration for V3
Projects
None yet
Development

No branches or pull requests

2 participants