validar número
This commit is contained in:
@@ -11,9 +11,9 @@ const nuevo = async (body, file) => {
|
||||
const idCarrera = validar.validarNumeroEntero(body.idCarrera, 'id carrera');
|
||||
const idStatus = validar.validarNumeroEntero(body.idStatus, 'id status');
|
||||
const numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
|
||||
const creditos = validar.validarNumero(body.creditos);
|
||||
const correo = validar.validarCorreo(body.correo);
|
||||
const telefono = validar.validarNumero(body.telefono, 15);
|
||||
const creditos = validar.validarNumero(body.creditos, 'créditos', true);
|
||||
const telefono = validar.validarNumero(body.telefono, 'teléfono', true, 15);
|
||||
const fechaInicio = validar.validarFecha(
|
||||
body.fechaInicio,
|
||||
'fecha de inicio',
|
||||
@@ -38,7 +38,7 @@ const nuevo = async (body, file) => {
|
||||
? validar.validarTexto(body.dependencia, 'dependencia', false, 200)
|
||||
: '';
|
||||
const motivo = body.motivo
|
||||
? validar.validarNumero(body.motivo, 'El texto motivo.', 1)
|
||||
? validar.validarNumero(body.motivo, 'motivo', true, 1)
|
||||
: '';
|
||||
let carpeta = '';
|
||||
const path = `./server/uploads/${validar.validar(file, 'El archivo', 1000)}`;
|
||||
|
||||
@@ -7,7 +7,14 @@ const Status = require(`${dbPath}/Status`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const serviciosEspeciales = async (body) => {
|
||||
const pagina = validar.validarNumero(body.pagina, true);
|
||||
const pagina = validar.validarNumero(
|
||||
body.pagina,
|
||||
'página',
|
||||
false,
|
||||
null,
|
||||
true,
|
||||
true
|
||||
);
|
||||
const where = body.idStatus
|
||||
? { idStatus: validar.validarNumeroEntero(body.idStatus, 'id status') }
|
||||
: { idStatus: { [Op.gt]: 10 } };
|
||||
|
||||
@@ -38,7 +38,12 @@ const update = async (body) => {
|
||||
200
|
||||
);
|
||||
if (body.telefono)
|
||||
dataUpdate.telefono = validar.validarNumero(body.telefono, 15);
|
||||
dataUpdate.telefono = validar.validarNumero(
|
||||
body.telefono,
|
||||
'teléfono',
|
||||
true,
|
||||
15
|
||||
);
|
||||
if (body.institucion)
|
||||
dataUpdate.institucion = validar.validarTexto(
|
||||
body.institucion,
|
||||
@@ -56,7 +61,8 @@ const update = async (body) => {
|
||||
if (body.motivo)
|
||||
dataUpdate.motivo = validar.validarNumero(
|
||||
body.motivo,
|
||||
'El texto motivo.',
|
||||
'motivo',
|
||||
true,
|
||||
1
|
||||
);
|
||||
if (validar.validarObjetoVacio(dataUpdate))
|
||||
|
||||
@@ -10,7 +10,7 @@ const Servicio = require(`${dbPath}/Servicio`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const get = async (body) => {
|
||||
const year = validarNumero(body.year, 4);
|
||||
const year = validarNumero(body.year, 'año', true, 4);
|
||||
const path = `server/uploads/${year}_cuestionario_alumno.csv`;
|
||||
const data = [];
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ const Programa = require(`${dbPath}/Programa`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const get = async (body) => {
|
||||
const year = validarNumero(body.year, 4);
|
||||
const year = validarNumero(body.year, 'año', true, 4);
|
||||
const path = `server/uploads/${year}_cuestionario_programa.csv`;
|
||||
const data = [];
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ const Servicio = require(`${dbPath}/Servicio`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const gustavoBazPrada = async (body) => {
|
||||
const year = validar.validarNumero(body.year, 4);
|
||||
const year = validar.validarNumero(body.year, 'año', true, 4);
|
||||
const inicio = moment(`${year}-01-31`);
|
||||
const fin = moment(`${parseInt(year) + 1}-01-31`);
|
||||
const path = `server/uploads/${year}_gustavo_baz_prada.csv`;
|
||||
|
||||
@@ -16,7 +16,7 @@ const nuevo = async (body, file) => {
|
||||
);
|
||||
const idCarrera = validar.validarNumeroEntero(body.idCarrera, 'id carrera');
|
||||
const numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
|
||||
const creditos = validar.validarNumero(body.creditos);
|
||||
const creditos = validar.validarNumero(body.creditos, 'créditos', true);
|
||||
const correo = validar.validarCorreo(body.correo);
|
||||
const fechaInicio = validar.validarFecha(
|
||||
body.fechaInicio,
|
||||
|
||||
@@ -17,7 +17,7 @@ const registroValidado = async (body) => {
|
||||
'fecha de nacimiento',
|
||||
false
|
||||
);
|
||||
const telefono = validar.validarNumero(body.telefono, 15);
|
||||
const telefono = validar.validarNumero(body.telefono, 'teléfono', true, 15);
|
||||
const direccion = validar.validarAlfanumerico(
|
||||
body.direccion,
|
||||
'dirección',
|
||||
|
||||
@@ -8,7 +8,14 @@ const Status = require(`${dbPath}/Status`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const serviciosAdmin = async (body) => {
|
||||
const pagina = validar.validarNumero(body.pagina, true);
|
||||
const pagina = validar.validarNumero(
|
||||
body.pagina,
|
||||
'página',
|
||||
false,
|
||||
null,
|
||||
true,
|
||||
true
|
||||
);
|
||||
const where = body.idStatus
|
||||
? { idStatus: validar.validarNumeroEntero(body.idStatus, 'id status') }
|
||||
: {};
|
||||
|
||||
@@ -9,7 +9,14 @@ const Status = require(`${dbPath}/Status`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const serviciosResponsable = async (body) => {
|
||||
const pagina = validar.validarNumero(body.pagina, true);
|
||||
const pagina = validar.validarNumero(
|
||||
body.pagina,
|
||||
'página',
|
||||
false,
|
||||
null,
|
||||
true,
|
||||
true
|
||||
);
|
||||
const idUsuario = validar.validarNumeroEntero(body.idUsuario, 'id usuario');
|
||||
const where = body.idStatus
|
||||
? { idStatus: validar.validarNumeroEntero(body.idStatus, 'id status') }
|
||||
|
||||
@@ -67,7 +67,12 @@ const update = async (body, files) => {
|
||||
200
|
||||
);
|
||||
if (body.telefono)
|
||||
dataUpdate.telefono = validar.validarNumero(body.telefono, 15);
|
||||
dataUpdate.telefono = validar.validarNumero(
|
||||
body.telefono,
|
||||
'teléfono',
|
||||
true,
|
||||
15
|
||||
);
|
||||
if (validar.validarObjetoVacio(dataUpdate))
|
||||
throw new Error(
|
||||
'No se envio nada para actualizar este Servicio Social'
|
||||
|
||||
@@ -3,7 +3,14 @@ const validar = require('../../helper/validar');
|
||||
const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const responsables = async (body) => {
|
||||
const pagina = validar.validarNumero(body.pagina, true);
|
||||
const pagina = validar.validarNumero(
|
||||
body.pagina,
|
||||
'página',
|
||||
false,
|
||||
null,
|
||||
true,
|
||||
true
|
||||
);
|
||||
const nombre = body.nombre
|
||||
? validar.validarTexto(body.nombre, 'nombre', true, 60)
|
||||
: '';
|
||||
|
||||
Reference in New Issue
Block a user