-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate.js
64 lines (58 loc) · 1.77 KB
/
validate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const warningMsg = document.getElementById("warning");
const expresiones = {
password: /^.{6,12}$/, // 6 a 12 digitos.
email: /^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/,
task: /^[!@#^&*,/\\\\~'<>]$/,
};
const validateTask = ({ expresion = expresiones.task, input }) => {
const arrTexto = [...input];
let count = 0;
errorMsg.textContent = "";
arrTexto.map(function (e) {
if (expresion.test(e)) {
count++;
}
});
if (count > 0) {
warningMsg.textContent = `Caracter no permitido, ingrese texo simple, por favor, si lo deja sera reemplazado por un espacio al agregar la tarea.
Total no permitidos ${count} .-
`;
} else {
warningMsg.textContent = "";
}
return count;
};
const validateInputs = ({ expresion, input,error }) => {
if (!expresion.test(input)) {
error.classList.remove('invisible')
return false;
}
error.classList.add('invisible')
return true;
};
const transformToValidateTaskText = (texto) => {
const arrTexto = [...texto];
return arrTexto
.map(function (e) {
return expresiones.task.test(e) ? "" : e;
})
.join("");
};
const handleError = ({code}) =>{
switch (code) {
case 'auth/wrong-password':
dangerLoginPasswordMsg.textContent='Clave Incorrecta'
dangerLoginPasswordMsg.classList.remove('invisible')
break;
case 'auth/user-not-found':
dangerLoginEmailMsg.textContent='Correo Incorrecto'
dangerLoginEmailMsg.classList.remove('invisible')
break;
case 'auth/email-already-in-use':
dangerSignUpEmailMsg.textContent='Correo ya existe'
dangerSignUpEmailMsg.classList.remove('invisible')
break;
default:
break;
}
}