-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValidators.js
More file actions
86 lines (84 loc) · 1.52 KB
/
Copy pathValidators.js
File metadata and controls
86 lines (84 loc) · 1.52 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
module.exports = class Validator
{
isString(str)
{
if(!str.length)
{
return false;
}
if(typeof str === 'string')
{
return true;
}
else
return false;
}
isNumber(num) {
if(typeof num ==='number')
{
return true;
}
return false;
}
isInteger(num) {
if(typeof num ==='number')
{
num = num.toString();
for(let i = 0; i < num.length;++i)
{
if(num.charCodeAt(i) < 48 || num.charCodeAt(i) > 57)
{
return false;
}
}
return true;
}
return false;
}
isFloat(num) {
if(typeof num ==='number')
{
num = num.toString();
for(let i = 0; i < num.length-1;++i)
{
if(num.charCodeAt(i)===46 )
{
return true;
}
}
return false;
}
return false;
}
isSpecialSymbol(sym)
{
if(!sym)
{
return false;
}
if(typeof sym === 'number')
{
return false;
}
if(typeof sym ==='object')
{
return false;
}
for(let ix = 0; ix < sym.length; ++ix)
{
if((sym.charCodeAt(ix) >= 48 && sym.charCodeAt(ix) <= 57) ||(sym.charCodeAt(ix) >= 65 && sym.charCodeAt(ix) <= 90) || (sym.charCodeAt(ix) >=97 && sym.charCodeAt(ix) <=122))
{
return false;
}
}
return true;
}
isDate(d)
{
if(typeof d.getMonth === 'function')
{
return true;
}
return false;
}
}