Skip to content

[FEAT] Ignore validation errors #37

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

Open
rm-shanebreeze opened this issue Jan 24, 2024 · 2 comments
Open

[FEAT] Ignore validation errors #37

rm-shanebreeze opened this issue Jan 24, 2024 · 2 comments

Comments

@rm-shanebreeze
Copy link

Is there a way to configure patito Models to ignore certain validation errors (e.g. type_error.superfluoscolumns) in the model class rather than catching and checking errors?

@dsgibbons
Copy link
Contributor

dsgibbons commented Aug 16, 2024

patito.validators.validate has an allow_superfluous_columns argument (https://github.com/JakobGM/patito/blob/main/src/patito/validators.py#L89). Can you give an example where you need this logic to live in the model rather than in the call to validate?

@lmmx lmmx added this to Planner Sep 9, 2024
@lmmx lmmx moved this to 🧊 On hold in Planner Sep 9, 2024
@lmmx lmmx moved this from 🧊 On hold to 🔙 Backlog in Planner Sep 9, 2024
@lmmx lmmx removed this from Planner Sep 14, 2024
@gab23r
Copy link

gab23r commented Feb 18, 2025

Patito should be better integrated with pydantic features. Configuration should be set in ConfigDict, not on the fly through the validate arguments. See how you do that the pydantic way:

from pydantic import BaseModel, ConfigDict
import patito as pt

class PydanticModel(BaseModel):
    model_config = ConfigDict(extra="allow")
        
    a: int

PydanticModel.model_validate({"a" : 1, "b": 1}) # works
# PydanticModel(a=1, b=1)

class Model(pt.Model):
    model_config = ConfigDict(extra="allow")
        
    a: int

Model.validate(Model.examples().with_columns(b = 1)) # fails
# Superfluous column (type=type_error.superfluouscolumns)

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

No branches or pull requests

3 participants