Skip to content

validate_assignment decorator improvements #1205

@samuelcolvin

Description

@samuelcolvin

Future improvements to the validate_assignment decorator #1179:

  • arguments to the decorator, including: validators, custom config (partially fixed by Valdiate arguments config #1663), return value validation
  • rewrite front page to explain the 3 or 4 primary interfaces to pydantic:
    • BaseModel
    • dataclasses
    • parse_obj_as
    • validate_arguments
  • perhaps change the error raised for invalid arguments to inherit from TypeError as other argument errors do. (Currently the normal ValidationError is raised which inherits from ValueError)
  • allow validate_assignment to be set in "strict" mode so types are not coerced, this is really just Strict configuration #1098
  • option to enable or disable validation via an environment variable or similar - e.g. to only use the function in development or testing or on a subset of calls
  • option to still call the function if validation fails
  • get rid of the extra arguments to the underlying model so it's useful
  • instance methods @validate_arguments on instance methods #1222

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions