-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvalidations.js
More file actions
60 lines (57 loc) · 1.62 KB
/
Copy pathvalidations.js
File metadata and controls
60 lines (57 loc) · 1.62 KB
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
'use strict'
// Module para verificar si es un string
export default function validateString(data){
try {
if(typeof(data) != "string" && data instanceof(String) == false){
throw new Error(` ==> Tipo de Dato ${typeof(data)} incorrecto!! `);
}
return true;
} catch (error) {
console.error(error);
return false;
}finally{
console.warn("==> Preprocessed text finished !!");
}
}
// Module para verificar si es un number
export function validateNumber(data){
try {
if(typeof(data) != "number" && data instanceof(Number) == false){
throw new Error(` ==> Tipo de Dato ${typeof(data)} incorrecto!! `);
}
return true;
} catch (error) {
console.error(error);
return false;
}finally{
console.warn("==> Preprocessed number finished !!");
}
}
// Modulo para validar Objetos
export function validateObjectDate(data){
try {
if(!(data instanceof Date)){
throw new Error(` ==> Tipo de Dato ${typeof(data)} incorrecto!! `);
}
return true;
} catch (error) {
console.error(error);
return false;
}finally{
console.warn("==> Preprocessed object finished !!");
}
}
// Modulo para validar Arrays
export function validateArray(data){
try {
if(!(data instanceof Array)){
throw new Error(` ==> Tipo de Dato ${typeof(data)} incorrecto!! `);
}
return true;
} catch (error) {
console.error(error);
return false;
}finally{
console.warn("==> Preprocessed array finished !!");
}
}