Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coerce on List elements produces unexpect results #161

Closed
proximous opened this issue Oct 12, 2015 · 2 comments
Closed

Coerce on List elements produces unexpect results #161

proximous opened this issue Oct 12, 2015 · 2 comments

Comments

@proximous
Copy link

Slight modification of the example at: http://cerberus.readthedocs.org/en/latest/usage.html

schema = {'a_list': {'type': 'list', 'schema': {'type': 'float', 'coerce': float}}}
document = {'a_list': [3, 4, 5]}
v.validated(document, schema)
>>> {0: 3.0, 1: 4.0, 2: 5.0, 'a_list': [3, 4, 5]}

I would expect:

>>> {'a_list': [3.0, 4.0, 5.0]}

Is this the intended behavior or a bug?

@funkyfuture
Copy link
Member

it's a bug and is propably found here: https://github.com/nicolaiarocci/cerberus/blob/master/cerberus/cerberus.py#L359

funkyfuture added a commit to funkyfuture/cerberus that referenced this issue Oct 16, 2015
also
- removes some unnecessary variable assignments
- changes how coercion within a valueschema is done, no more interferes with configuration

solves pyeve#161
funkyfuture added a commit to funkyfuture/cerberus that referenced this issue Oct 16, 2015
also
- removes some unnecessary variable assignments
- changes how coercion within a valueschema is done, no more interferes with configuration

solves pyeve#161
@proximous
Copy link
Author

Patch 165 from @funkyfuture fixes this issue. Many thanks!

nicolaiarocci pushed a commit that referenced this issue Oct 19, 2015
also
- removes some unnecessary variable assignments
- changes how coercion within a valueschema is done, no more interferes with configuration

solves #161
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants