'coerce' still ignores 'nullable': True
See original GitHub issue#269 was fixed, but only for integer:
>>> v = cerberus.Validator({'foo': {'coerce': int, 'nullable': True, 'type': 'integer'}})
>>> v.normalized({'foo': None})
{'foo': None}
Just replace integer to string:
>>> v = cerberus.Validator({'foo': {'coerce': str, 'nullable': True, 'type': 'string'}})
>>> v.normalized({'foo': None})
Expected behavior: {'foo': None}
Actual behavior: {'foo': 'None'}
So I still have to use a workaround 'coerce': lambda x: str(x) if x is not None else None
But now I’m not sure if it’s a bug or a feature (duplicate of #142?). If this is a feature, please describe this behavior in the documentation
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
'coerce' ignores 'nullable': True #269 - pyeve/cerberus - GitHub
I think, nullable should be checked first, and if value is None, then coerce callable should not be called. If it's a bug...
Read more >Swashbuckle SwaggerGen ignores nullable annotations on ...
Nullable = true , the generator still ignores it and doesn't insert the nullable annotation when there is a $ref in the schema...
Read more >Using nullability in GraphQL
A field can either be nullable or non-null, and this tells you whether or not you could receive a null value when you...
Read more >Dealing with null in Spark - MungingData
The isEvenBetter function is still directly referring to null. Let's do a final refactoring to fully remove null from the user defined function....
Read more >Working with missing data — pandas 1.5.2 documentation
In [11]: None == None # noqa: E711 Out[11]: True In [12]: np.nan == np.nan ... Support for integer NA for more). pandas...
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
@funkyfuture You’re delegating to Vietnam here, so much for the heat 😉. I will take a look at it and get back to you until wednesday.
not sure which of the previously behaviours you mean. 😉 anyway, no, for now we shouldn’t change any of that. just fix your tests (and possibly code to comply w/ them).