Merge pull request #1024 from strongloop/use_g.f_insteadof_utils.format

Use g.f instead of utils.format
This commit is contained in:
Amir-61 2016-08-03 12:08:32 -04:00 committed by GitHub
commit f2edbd91c3
2 changed files with 14 additions and 14 deletions

View File

@ -1243,7 +1243,7 @@ DataAccessObject._normalize = function(filter) {
}
var err = null;
if ((typeof filter !== 'object') || Array.isArray(filter)) {
err = new Error(g.f(util.format('The query filter %j is not an {{object}}', filter)));
err = new Error(g.f('The query filter %j is not an {{object}}', filter));
err.statusCode = 400;
throw err;
}
@ -1251,14 +1251,14 @@ DataAccessObject._normalize = function(filter) {
var limit = Number(filter.limit || 100);
var offset = Number(filter.skip || filter.offset || 0);
if (isNaN(limit) || limit <= 0 || Math.ceil(limit) !== limit) {
err = new Error(g.f(util.format('The {{limit}} parameter %j is not valid',
filter.limit)));
err = new Error(g.f('The {{limit}} parameter %j is not valid',
filter.limit));
err.statusCode = 400;
throw err;
}
if (isNaN(offset) || offset < 0 || Math.ceil(offset) !== offset) {
err = new Error(g.f(util.format('The {{offset/skip}} parameter %j is not valid',
filter.skip || filter.offset)));
err = new Error(g.f('The {{offset/skip}} parameter %j is not valid',
filter.skip || filter.offset));
err.statusCode = 400;
throw err;
}
@ -1289,7 +1289,7 @@ DataAccessObject._normalize = function(filter) {
if (dir === 'ASC' || dir === 'DESC') {
token = parts[0] + ' ' + dir;
} else {
err = new Error(g.f(util.format('The {{order}} %j has invalid direction', token)));
err = new Error(g.f('The {{order}} %j has invalid direction', token));
err.statusCode = 400;
throw err;
}
@ -1297,7 +1297,7 @@ DataAccessObject._normalize = function(filter) {
fields.push(token);
}
} else {
err = new Error(util.format('The order %j is not valid', order[i]));
err = new Error('The order %j is not valid', order[i]);
err.statusCode = 400;
throw err;
}
@ -1366,7 +1366,7 @@ DataAccessObject._coerce = function(where) {
var err;
if (typeof where !== 'object' || Array.isArray(where)) {
err = new Error(g.f(util.format('The where clause %j is not an {{object}}', where)));
err = new Error(g.f('The where clause %j is not an {{object}}', where));
err.statusCode = 400;
throw err;
}
@ -1381,7 +1381,7 @@ DataAccessObject._coerce = function(where) {
self._coerce(clauses[k]);
}
} else {
err = new Error(g.f(util.format('The %s operator has invalid clauses %j', p, clauses)));
err = new Error(g.f('The %s operator has invalid clauses %j', p, clauses));
err.statusCode = 400;
throw err;
}
@ -1440,14 +1440,14 @@ DataAccessObject._coerce = function(where) {
case 'inq':
case 'nin':
if (!Array.isArray(val)) {
err = new Error(g.f(util.format('The %s property has invalid clause %j', p, where[p])));
err = new Error(g.f('The %s property has invalid clause %j', p, where[p]));
err.statusCode = 400;
throw err;
}
break;
case 'between':
if (!Array.isArray(val) || val.length !== 2) {
err = new Error(g.f(util.format('The %s property has invalid clause %j', p, where[p])));
err = new Error(g.f('The %s property has invalid clause %j', p, where[p]));
err.statusCode = 400;
throw err;
}
@ -1455,7 +1455,7 @@ DataAccessObject._coerce = function(where) {
case 'like':
case 'nlike':
if (!(typeof val === 'string' || val instanceof RegExp)) {
err = new Error(g.f(util.format('The %s property has invalid clause %j', p, where[p])));
err = new Error(g.f('The %s property has invalid clause %j', p, where[p]));
err.statusCode = 400;
throw err;
}

View File

@ -19,7 +19,7 @@ function List(items, itemType, parent) {
try {
items = JSON.parse(items);
} catch (e) {
var err = new Error(g.f(util.format('could not create List from {{JSON}} string: %j', items)));
var err = new Error(g.f('could not create List from {{JSON}} string: %j', items));
err.statusCode = 400;
throw err;
}
@ -30,7 +30,7 @@ function List(items, itemType, parent) {
items = items || [];
if (!Array.isArray(items)) {
var err = new Error(g.f(util.format('Items must be an array: %j', items)));
var err = new Error(g.f('Items must be an array: %j', items));
err.statusCode = 400;
throw err;
}