Improve naming
This commit is contained in:
parent
2ff410946a
commit
9905b20448
@ -1,5 +1,5 @@
|
||||
const positiveIntegerNumber = /^\d+$/;
|
||||
const integerNumber = /^-?\d+$/;
|
||||
const positiveIntegerNumberRegExp = /^\d+$/;
|
||||
const integerNumberRegExp = /^-?\d+$/;
|
||||
const invalidZoomMessage = function (zoom) {
|
||||
return `Invalid zoom value (${zoom}). It should be an integer number greather or equal to 0`;
|
||||
};
|
||||
@ -14,7 +14,7 @@ module.exports = function coordinates (validate = { z: true, x: true, y: true })
|
||||
return function coordinatesMiddleware (req, res, next) {
|
||||
const { z, x, y } = req.params;
|
||||
|
||||
if (validate.z && !positiveIntegerNumber.test(z)) {
|
||||
if (validate.z && !positiveIntegerNumberRegExp.test(z)) {
|
||||
const err = new Error(invalidZoomMessage(z));
|
||||
err.http_status = 400;
|
||||
|
||||
@ -22,14 +22,14 @@ module.exports = function coordinates (validate = { z: true, x: true, y: true })
|
||||
}
|
||||
|
||||
// Negative values for x param are valid. The x param is wrapped
|
||||
if (validate.x && !integerNumber.test(x)) {
|
||||
if (validate.x && !integerNumberRegExp.test(x)) {
|
||||
const err = new Error(invalidCoordXMessage(x));
|
||||
err.http_status = 400;
|
||||
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if (validate.y && !positiveIntegerNumber.test(y)) {
|
||||
if (validate.y && !positiveIntegerNumberRegExp.test(y)) {
|
||||
const err = new Error(invalidCoordYMessage(y));
|
||||
err.http_status = 400;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user