From 6130f055b3a934a6e718fdb5cb2bf2895a68b940 Mon Sep 17 00:00:00 2001 From: xXpuma99Xx <51341582+xXpuma99Xx@users.noreply.github.com> Date: Sun, 2 Jan 2022 19:34:55 -0600 Subject: [PATCH] validar numero corregido --- server/helper/validar.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/server/helper/validar.js b/server/helper/validar.js index d1a4849..77ebfe4 100644 --- a/server/helper/validar.js +++ b/server/helper/validar.js @@ -1,5 +1,6 @@ const moment = require('moment'); const validator = require('validator'); +const Servicio = require('../db/tablas/Servicio'); // Caractéres especiales permitidos en una string const caracterEspecial = (char) => { @@ -34,6 +35,7 @@ const yaExiste = (campo, m) => { }; const noValido = (campo, m, razon) => { + console.log(m); throw new Error( `${m ? 'El' : 'La'} ${campo} no es valid${m ? 'o' : 'a'}, ${razon}.` ); @@ -121,7 +123,7 @@ const validarNumeroCuenta = ( ) => { validacionBasicaStr(numeroCuenta, campo, m, 9); if (!validator.isNumeric(numeroCuenta, { no_symbols: true })) - noValido(campo, m, 'tiene caracteres que nos son números'); + noValido(campo, m, 'tiene caracteres que no son números'); return numeroCuenta; }; @@ -148,7 +150,8 @@ const validarNumero = ( makeNumber = false ) => { validacionBasicaStr(numero, campo, m, length); - if (!validator.isNumeric(numero, { no_symbols })) noValido(campo); + if (!validator.isNumeric(numero, { no_symbols })) + noValido(campo, m, 'tiene caracteres que no son números'); if (makeNumber) return Number(numero); return numero; }; @@ -167,6 +170,25 @@ const validarObjetoVacio = (obj) => { return true; }; +const validarPreTermino = (idServicio) => { + return Servicio.findOne({ where: { idServicio } }) + .then((res) => { + if ( + res.idCuestionarioPrograma && + res.idCuestionarioAlumno && + res.cartaTermino && + res.informeGlobal + ) + return Servicio.update({ idStatus: 5 }, { where: { idServicio } }); + return false; + }) + .then((res) => + res + ? 'Este Servicio Social paso a Termino, espera a que COESI autorice tu liberación.' + : '' + ); +}; + module.exports = { yaExiste, noValido, @@ -180,4 +202,5 @@ module.exports = { validarFecha, validarNumero, validarObjetoVacio, + validarPreTermino, };