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
This code works for a validator like formencode.validators.FieldsMatch which only invalidates the current level of the dict. But if the validator is another Schema validator which returns a nested error_dict, the structure of the resulting error dict is inconsistent.
The following is an example unit test: test_sample.py
$ nosetests test_sample.py
F
======================================================================
FAIL: test_sample.test_partial_form_with_nested_forms_validators
----------------------------------------------------------------------
Traceback (most recent call last):
File "VirtualEnvs/formencode/lib/python3.6/site-packages/nose/case.py", line 198, in runTest
self.test(*self.arg)
File "/Repositories/git/3rdparty/formencode/test_sample.py", line 89, in test_partial_form_with_nested_forms_validators
assert expected_error.error_dict == partial_error.error_dict
AssertionError:
>> assert Invalid('chained_test: a_confirm: Fields do not match\nb_confirm: Fields do not match', {'chained_test': {'a': '1', 'a_confirm': '2', 'b': '3', 'b_confirm': '4'}}, None, None, {'chained_test': Invalid('a_confirm: Fields do not match\nb_confirm: Fields do not match', {'a': '1', 'a_confirm': '2', 'b': '3', 'b_confirm': '4'}, None, None, {'a_confirm': 'Fields do not match', 'b_confirm': 'Fields do not match'})}).error_dict == Invalid('chained_test: a_confirm: Fields do not match \nb_confirm: Fields do not match', {'chained_test': {'a': '1', 'a_confirm': '2', 'b': '3', 'b_confirm': '4'}}, None, None, {'chained_test': {'a_confirm': 'Fields do not match', 'b_confirm': 'Fields do not match'}}).error_dict
----------------------------------------------------------------------
Ran 1 test in 0.023s
FAILED (failures=1)
The text was updated successfully, but these errors were encountered:
The code merging the invalid result from the
validate_partial
function cannot handle complex/nested invalid errors.https://github.com/formencode/formencode/blob/2.0.0a1/formencode/schema.py#L205-L216
This code works for a validator like
formencode.validators.FieldsMatch
which only invalidates the current level of the dict. But if the validator is another Schema validator which returns a nested error_dict, the structure of the resulting error dict is inconsistent.The following is an example unit test: test_sample.py
Sample run:
The text was updated successfully, but these errors were encountered: