You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
>>> Scheme(choices).validate("hello")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: value did not pass any validation
This would be clearer
>>> Scheme(choices).validate("hello")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: value was not one of "choiceA", "choiceB", "choiceC".
The text was updated successfully, but these errors were encountered:
In above example, the <value> will be validated without error in any of the following case:
If value is an integer greater than 100
If value is an integer less than 0
If value is string "hello"
If value is a dict with string keys and integer values
Printing out "value was not one of " followed by the above list would be cryptic since it would print out lambda functions and dicts in the error message
Simply put, the syntax of Any is Any([validator1, validator2,....]) and is not Any(["str1", "str2",...]).
Also, if the list of validators is very long, error message would end up being long too.
Yes both are possible and I too believe that the error message for Any validator would be better that way.. I did not get enough time to format it. So it is left as it is. That said, if someone adds this and creates a PR, I would happily merge it.
Instead of:
This would be clearer
The text was updated successfully, but these errors were encountered: