Nested Custom Coercers Not Applied
See original GitHub issueUsed Cerberus version / latest commit: Cerberus==1.1
-
I consulted these documentations:
-
I consulted these sections of the docs (add more lines as necessary):
- …
- …
-
I found nothing relevant to my problem in the docs.
-
I found the documentation not helpful to my problem.
-
I have the capacity to improve the docs when my problem is solved.
-
I have the capacity to submit a patch when a bug is identified.
Support request / Bug report
I am trying to apply a custom coercer to a nested item. I do not believe this is working properly. To simplify this, I modified the example code from the documentation to demonstrate the issue:
class MyNormalizer(Validator):
def __init__(self, multiplier, *args, **kwargs):
super(MyNormalizer, self).__init__(multiplier=multiplier, *args, **kwargs)
self.multiplier = multiplier
def _normalize_coerce_multiply(self, value):
return value * self.multiplier
schema = {
'foo': {
'type': 'list',
'schema': {
'sub_foo': {
'coerce': 'multiply'
}
}
}
}
document = {'foo': [{'sub_foo': 2}]}
MyNormalizer(2).normalized(document, schema)
# Expected Output: {'foo': [{'sub_foo': 4}]}
# Output: {'foo': [{'sub_foo': 2}]}
I believe the schema definition / custom Validator
class is accurate. Please let me know if this is not the case.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Javax validation on nested objects - not working
In my Spring Boot project I have two DTO's which I'm trying to validate, LocationDto and BuildingDto. The LocationDto has a nested object...
Read more >Rules for nested data not applying if parent schema has errors ...
Describe the bug When applying a rule for nested data, like rule("user.name"), it will fail to run if any of the other user...
Read more >Cerberus Documentation - manpages.ubuntu!
Simple custom errors A simpler form is to call _error() with the field and a string as message. However the resulting error will...
Read more >Cerberus Changelog
New function-based custom validation mode (Luo Peng). Fields with empty definitions in schema were reported as non-existent. Now they are considered as valid, ......
Read more >valico - crates.io: Rust Package Registry
What is Valico? Build Status. Valico is a validation and coercion tool for JSON objects, written in Rust. It designed to be a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@fermuch normalization rules in
*of
rules are not applied. see #344 / 17e786b@sireliah at the time values are coerced, the document will not have a field with any rules in the schema. see #345
Hey, I found similar issue with nested structures when you:
It would be nice this to work in such way that you are able to modify the parent element first and then apply changes to all child elements. If there is no easy fix, I can try to find a way.