From 0ce6b8b606ed087c22b367a4aa1d9c970cc279d9 Mon Sep 17 00:00:00 2001 From: Emmanuel Kiametis Date: Tue, 15 Oct 2019 12:18:16 -0300 Subject: [PATCH] Aceitando campo 'valor' com valor = 0 (ZERO) --- api/http-validators/commum.js | 6 +++++- package.json | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/api/http-validators/commum.js b/api/http-validators/commum.js index f1e0933..203f81c 100644 --- a/api/http-validators/commum.js +++ b/api/http-validators/commum.js @@ -1,7 +1,11 @@ const { ResponseError, Err, Response } = require('../util'); const campoObrigatorio = (nomeCampo, valor, options = { isRequest: true }) => { - if(typeof valor !== 'boolean' && !valor) { + const tipo = typeof valor; + if(tipo === 'number' && valor === 0) { + return; + } + if(tipo !== 'boolean' && !valor){ if(options.isRequest) { Err.throwError(Response.HTTP_STATUS.BAD_REQUEST, 997000, 1, { campo: nomeCampo }); } else { diff --git a/package.json b/package.json index c348126..07a1b38 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "qrpague-server-nodejs", - "version": "3.3.1", + "version": "3.3.2", "scripts": { "start": "pm2 start app.js", "debug": "node index.js",