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
In the below example (ignoring programming logic) field validators are called multiple times. Is this bug or not?
In [201]: def is_names_empty(value):
...: print("Is Names Empty?")
...: return value
In [202]: def is_duplicate(value):
...: print("Is Duplicate?")
...: return value
In [203]: class A(Model):
...: id=StringType()
...: names=ListType(StringType, validators=[is_names_empty])
...: black_list=ListType(StringType, validators=[is_duplicate])
...:
...: def validate_names(self, validated, new_data):
...: print(f"New Data: {new_data}")
...: print(f"Validated: {validated}")
...: if any([n in validated["black_list"] for n in new_data]):
...: raise ValidationError("Blacklisted name found")
In [204]: a=A();a.id=1;a.names=["kk"];a.black_list=["jj"];a.validate()
Is Names Empty?
Is Names Empty?
Is Duplicate?
Is Duplicate?
New Data: ['kk']
Validated: {'id': '1', 'names': ['kk'], 'black_list': ['jj']}
In [205]: a=A();a.id=1;a.names=["kk"];a.black_list=["jj","kk"];a.validate()
Is Names Empty?
Is Names Empty?
Is Duplicate?
Is Duplicate?
Is Duplicate?
New Data: ['kk']
Validated: {'id': '1', 'names': ['kk'], 'black_list': ['jj', 'kk']}
---------------------------------------------------------------------------
DataError Traceback (most recent call last)
<< Truncated trackeback>>
DataError: {"names": ["Blacklisted name found"]}
Even if model validator has to call field validator, why is_duplicate is called 3 times ?
The text was updated successfully, but these errors were encountered:
In the below example (ignoring programming logic) field validators are called multiple times. Is this bug or not?
Even if
model validator
has to callfield validator
, whyis_duplicate
is called 3 times ?The text was updated successfully, but these errors were encountered: