Allow custom Defaults to raise exceptions for conditional defaults #108
Labels
enhancement
Improvements to existing features or smaller new features
new feature
New feature that is not (only) a validator class
Milestone
Currently, if a custom Default class raises an exception, this exception would not be handled.
A potential use case for this are "conditional defaults": Having a field that is required under certain (external) conditions, but has a default otherwise. The
Default
object would either return a default value or raise an exception if the field is supposed to be required.Proposal: The
DataclassValidator
should catch specific exceptions when filling in default values and treat them as "this field is required". However, this should not allow just any exception. There should be either a specific new exception for this usecase (NoDefaultException?), or theDictRequiredFieldError
should be used.The text was updated successfully, but these errors were encountered: