Skip to content

Commit

Permalink
improved, default param value for validateParams to support null values
Browse files Browse the repository at this point in the history
  • Loading branch information
SkeloGH committed Dec 22, 2019
1 parent cbe1508 commit 422490d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions bin/commands/add/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,19 @@ const clientExists = (client) => {
});
return res;
};
const validateParams = (config = {}) => {
const validateParams = (config) => {
const _config = config || {};
const msgIntro = '[Invalid or missing parameter value]';
const validation = { valid: true, message: null };
if (config.type === 'target' && (!config.origin || !config.origin.length)) {
if (_config.type === 'target' && (!_config.origin || !_config.origin.length)) {
validation.valid = false;
validation.message = `${msgIntro} 'origin', a target client's 'origin' should be the name of a 'source' client.`;
}
if (!config.name || !config.name.length) {
if (!_config.name || !_config.name.length) {
validation.valid = false;
validation.message = `${msgIntro} 'name', the client database name, ex: my_${config.type}_db .`;
validation.message = `${msgIntro} 'name', the client database name, ex: my_${_config.type}_db .`;
}
if (!config.url || !config.url.length) {
if (!_config.url || !_config.url.length) {
validation.valid = false;
validation.message = `${msgIntro} 'url', the client database url, ex: mongodb://localhost:27017 .`;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/bin/commands/add/client.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 422490d

Please sign in to comment.