You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a problem with the current way of setting default values when using validators.
The method _validate_items should have no side effect on the object being validated, inside that method, teh settings must be read only to perform the validation.
Currently this method calls set twice to set default values and apply cast transformation.
This is causing problems with the inspect history and is duplicating the calls to set
Proposal
Stop calling set on validate_items
Collect defaults and cast from registered validators
Refactoring
Stop calling set and setdefault inside _validate_items
change this block to value = settings.get(name, empty)
On ValidatorList.register iterate all validators and register its default and cast parameter on settings._validators_defaults: DynaBox (OR store it on the instance of ValidatorList itself
On Settings.getline change the implementation to raise KeyError and then on except lookup the self._validators_defaults else default
On line lookup for cast also on self._validators_defaults if not passed directly to get
On Settings init create an instance of ValidatorsList and then call the register on it, also change ValidatorList init to pass accepted args to register instead of super
The text was updated successfully, but these errors were encountered:
There is a problem with the current way of setting default values when using validators.
The method
_validate_items
should have noside effect
on the object being validated, inside that method, tehsettings
must be read only to perform the validation.Currently this method calls set twice to set default values and apply cast transformation.
here and here
This is causing problems with the
inspect
history and is duplicating the calls toset
Proposal
set
onvalidate_items
Refactoring
set
andsetdefault
inside_validate_items
value = settings.get(name, empty)
ValidatorList.register
iterate all validators and register itsdefault
andcast
parameter onsettings._validators_defaults: DynaBox
(OR store it on the instance of ValidatorList itselfSettings.get
line change the implementation to raiseKeyError
and then on except lookup theself._validators_defaults
elsedefault
cast
also onself._validators_defaults
if not passed directly toget
The text was updated successfully, but these errors were encountered: