Comments (3)
It's hard to type the same message every time, or even abstract to constants.
Some people use custom helpers for this. You can even override a built-in one to provide a default:
LGTM.helpers.register('required', function(message="Please provide a value.") {
this.using(function(value) {
return value !== null && value !== undefined && value !== '';
}, message);
});
As for why required()
does not result in valid: false
, I believe it's due to this part of ObjectValidator
. The behavior is wrong, but I would argue that the right thing is to throw when no message is provided. What do you think?
from lgtm.
Well, I still think that defaults should be provided by default and, if the user uses undefined or null as a message, then throw an useful exception
from lgtm.
Tracking the issue raised in #17.
from lgtm.
Related Issues (20)
- LGTM standalone | $$config$$config.async method is undefined HOT 2
- Question: why is validation response structure like it is? HOT 6
- Composing chained validations from multiple validators HOT 2
- Ensure `required` calls without a message fail
- Publish sourcemaps HOT 2
- Dynamic messages HOT 1
- Online demo is broken HOT 1
- Add support for custom message HOT 5
- Version 10 of node.js has been released
- The automated release is failing 🚨 HOT 4
- Changing input values as part of validation? HOT 2
- Current version on NPM doesn't include commonjs build HOT 3
- An in-range update of mocha is breaking the build 🚨 HOT 8
- An in-range update of rollup is breaking the build 🚨 HOT 87
- An in-range update of gzip-size is breaking the build 🚨 HOT 2
- Dependent validations cause duplicate errors HOT 1
- An in-range update of uglify-js is breaking the build 🚨 HOT 17
- An in-range update of babel7 is breaking the build 🚨 HOT 18
- [Feature Request] Validations on a nested object. HOT 4
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 lgtm.