8000 Clarify the purpose of pydantic e.g. not strict validation · Issue #578 · pydantic/pydantic · GitHub
[go: up one dir, main page]

Skip to content

Clarify the purpose of pydantic e.g. not strict validation #578

@samuelcolvin

Description

@samuelcolvin

ref #284 and #360

Pydantic is no a validation library, it's a parsing library.

It makes no guarantee whatsoever about checking the form of data you give to it; instead it makes a guarantee about the form of data you get out of it.

This sounds like an esoteric difference, but it has real practical consequences, eg.

  • if you pass "3" (which is not an int) to an int field, pydantic will convert it to an int
  • if you pass 3.14 (which again is not an int) to an int field, pydantic will convert it to an int (thereby "loosing information")

I think this is correct and I'm not interested in changing it, but we should be clear about what pydantic is/does - while I was annoyed by the manor of the question in #284 (sorry, wrong issue, I meant #360) I do understand the motivation for the question.

To fix this we should:

  • add the above statement prominently to the docs
  • rename validate_model to parse_model (this will require the old version to continue to work with a deprecation warning for 2 versions)
  • rename __get_validators__ to __get_parser_functions__ or similar (again will require the old function to continue to work with a deprecation warning)
  • remove use of "validate"/"validation" from the docs

This is a big, backwards incompatible change for no material benefit but I think it's worth it for clarity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0