Skip to content

Should properties validate against their model? #248

@rwb27

Description

@rwb27

Currently, lt.property only validates values sent over HTTP. Values set in Python are accepted as-is, so we do no validation.

We could change this behaviour to use the model for the property to validate it when it's set. This would be a change to behaviour and might incur a small performance penalty. However, in exchange we'd get two advantages:

  1. We'd know that the value of a property has always been validated against the model (which includes e.g. numeric constraints).
  2. Properties whose value is a BaseModel subclass could be set by supplying a dict as well as supplying a BaseModel (though mypy would complain if this is done explicitly).

Opinions welcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionDiscussion about how something should be doneenhancementNew feature or requestroadmapPlans for the future

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions