question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Usage of allowed and nullable params

See original GitHub issue

I’m have a issues when use allowed and nullable params

Use-case abstract

 schemas = [
    {'role': {'type': 'string', 'allowed': ['agent', 'client', 'supplier']}},
    {'role': {'type': 'string', 'allowed': ['agent', 'client', 'supplier', None]}},
    {'role': {'type': 'string', 'allowed': ['agent', 'client', 'supplier'], 'nullable': True}},
    {'role': {'type': 'string', 'allowed': ['agent', 'client', 'supplier', None], 'nullable': True}},
    {'role': {'type': 'string', 'nullable': True}},
]
data = [
    {'role': 'agent'},
    {'role': None},
]

Output from cerberus

Version - 1.2
Schema # 	   Data
   1		True  False  
   2		True  False  
   3		True  False  
   4		True  True  
   5		True  True  

Version - 1.1
Schema # 	   Data
   1		True  False  
   2		True  False  
   3		True  True  
   4		True  True  
   5		True  True  

Bug report / Feature request

As we can see in v1.2 have different ouput with nullable param (3td schema). It looks like a bug In my oppinion v1.1 working more properly

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
cpforbescommented, Jan 17, 2019

It looks like 74c015b57a7224d1a6fdc30e7c7f0779489c39df introduced the change.

It seems that allowed needs to be added the the call to _drop_remaining_rules in order to match the 1.1 behavior.

0reactions
funkyfuturecommented, Jan 27, 2019

no, on the contrary, no rules were skipped at all some rules caused remaining rules to be dropped, others didn’t.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Optional and Nullable Properties in API Requests
Learn how optional and nullable properties can be used flexibly in combinations in each parameter of your API requests made from a SDK....
Read more >
Simplified parameters, nullable means optional #2232 - GitHub
Omitting an argument means that null will be the value of the parameter, unless it has a default value, then the default value...
Read more >
Nullable and @NotNull - IntelliJ IDEA - JetBrains
@Nullable​​ The @Nullable annotation helps you detect: Method calls that can return null. Variables (fields, local variables, and parameters), that can be null....
Read more >
How to allow for null parameters in API Attribute Routing?
Is there a way I can modify the route to allow for when 1 or more parameters are null/empty strings?
Read more >
Java: Why not allow nulls in methods to represent optional ...
In general it is a bad idea to use null to indicate an optional value. It is a bad idea whether it is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found