Skip to content

Commit

Permalink
Aceitando campo 'valor' com valor = 0 (ZERO)
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel Kiametis committed Oct 15, 2019
1 parent 88d93ae commit 0ce6b8b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion api/http-validators/commum.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 0ce6b8b

Please sign in to comment.