Giter VIP home page Giter VIP logo

Comments (7)

Viicos avatar Viicos commented on July 17, 2024 1

Yes my bad it's only with a plain validator that nothing gets called after the plain validator!

from pydantic.

OhioDschungel6 avatar OhioDschungel6 commented on July 17, 2024 1

Oke perfect, thanks :)

from pydantic.

Viicos avatar Viicos commented on July 17, 2024

This is the expected behavior of the before (model) validator, the input is untouched. You probably want to use an after model validator: in this case, value["a"] will be a Decimal instance. If you need more flexibility, you can also use a wrap validator

from pydantic.

OhioDschungel6 avatar OhioDschungel6 commented on July 17, 2024

Please note, that I am not doing any validation. I am using the BeforeValidator as simple hook, to do something else before the validation starts.
From my POV a noop BeforeValidator should not break the validation.
From the docs i would expect that a, b and c are strings at the before validation stage.
Also decimal seems to have another problem with lossy data, which may or may not be related to the data being passed as float instead of a string.

from pydantic.

OhioDschungel6 avatar OhioDschungel6 commented on July 17, 2024

After thinking some more about it, i guess that pydantic is switching from json validation to python validation, when a BeforeValidator exists. This would be quite strange behaviour.

On the data type in the BeforeValidator side note: probably everything should be a string at this stage. For ints it is no problem, but floats have already lost precision at this point (I can not get it back at this stage), if i want to do my own validation.

from pydantic.

sydney-runkle avatar sydney-runkle commented on July 17, 2024

Hmm, I would still expect this to work with a before validator. I'll chat with the team first thing tomorrow and solidify whether or not this is expected behavior.

Thanks for reporting this issue!

from pydantic.

sydney-runkle avatar sydney-runkle commented on July 17, 2024

Indeed, this is a bug!

from pydantic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.