Rename and Coerce do not work together
>>> import cerberus
>>> cerberus.__version__
'1.3.4'
>>> from cerberus.validator import Validator
>>> Validator().normalized({'f': '123'}, schema={'f': {'type': 'integer', 'coerce': int}})
{'f': 123}
>>> Validator().normalized({'f': '123'}, schema={'f': {'type': 'integer', 'coerce': int, 'rename': 'g'}})
{'g': '123'}
I would expect the coerce to still take effect here. Please let me know whether this is intended behavior or if there is another way to do what I intended.
yes, it is a known issue that people walk into by intuition. be aware that validation rules are validated against the normalized document.
i keep this issue open as a reminder that admonitions that point people to the proper considerations should be added to the docs about schemas and normalization rules. also, the former should be renamed to just "Schemas". other documents and docstrings also still state "validation schemas" (sometimes joined w/ a dash) though they are meant generally.
also rename and default don't work together
>>>from cerberus import Validator
>>>v = Validator({'foo': {'default': '1', 'rename': 'bar'}})
>>>print(v.normalized({'foo': 2}))
{'bar': 2, 'foo': '1'}
#expect result
{'bar': 2}
i think rename should process at last in function __normalize_mapping