Comments (3)
Any
validator is a generic validator (Simple list of string choices is only one of the possibilites here). Following example demonstrates what i mean:
lambdas = validators.Any([lambda x: x > 100, lambda x: x < 0, "hello", {str: int}])
lambdas.validate( <value> )
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 dict
s 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.
from pyschemes.
In which case something like::
Value was not one of "x > 100", "x < 0", "hello", "{str: int}"
Would be clearer.
(code inside lambdas can be extracted using the inspect module.)
Also, if the list of validators is very long, error message would end up being long too.
So truncate?
from pyschemes.
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.
from pyschemes.
Related Issues (3)
- Validating False HOT 1
- General question. HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyschemes.