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:
- We'd know that the value of a property has always been validated against the model (which includes e.g. numeric constraints).
- 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.
Currently,
lt.propertyonly 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
modelfor 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:BaseModelsubclass could be set by supplying adictas well as supplying aBaseModel(thoughmypywould complain if this is done explicitly).Opinions welcome.