enviar datos correctos al responsable

This commit is contained in:
Lemuel Marquez
2020-11-27 12:36:53 -06:00
parent 7419b81868
commit bde94edb60
10 changed files with 32 additions and 17 deletions
+4 -4
View File
@@ -46,9 +46,9 @@ const caracteresEspeciales = (char) => {
return false;
};
const validarTexto = (texto, campo) => {
const validarTexto = (texto, campo, length) => {
noHay(texto, campo);
if (typeof texto !== 'string') noValido(campo);
if (typeof texto !== 'string' || texto.length > length) noValido(campo);
for (let i = 0; i < texto.length; i++) {
if (caracteresEspeciales(texto[i])) continue;
if (!validator.isAlpha(texto[i], 'es-ES')) noValido(campo);
@@ -56,9 +56,9 @@ const validarTexto = (texto, campo) => {
return texto;
};
const validarAlfanumerico = (texto, campo) => {
const validarAlfanumerico = (texto, campo, length) => {
noHay(texto, campo);
if (typeof texto !== 'string') noValido(campo);
if (typeof texto !== 'string' || texto.length > length) noValido(campo);
for (let i = 0; i < texto.length; i++) {
if (caracteresEspeciales(texto[i])) continue;
if (!validator.isAlphanumeric(texto[i], 'es-ES')) noValido(campo);