JakobGM / patito

A data modelling layer built on top of polars and pydantic
MIT License
252 stars 23 forks source link

are pydantic BeforeValidator and AfterValidator annotations supported? #42

Open hottwaj opened 5 months ago

hottwaj commented 5 months ago

Thanks!

chainyo commented 5 months ago

Hi, from my testing this is not working when you load data with polars and then validate the polars.DataFrame with the pre-defined model, e.g.:

data = polars.read_csv("data.csv", has_header=True)
try:
    Model.validate(data)
except Exception as e:
    print(e)

It doesn't work either this way:

data = Model.DataFrame.read_csv("data.csv", has_header=True)

BUT it works if you create the object directly: Model(*args, **kwargs)