forked from froncubator/validator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
validator.js
59 lines (52 loc) · 1.15 KB
/
validator.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
function isEmail(value) {
if (typeof value == 'string' && value.indexOf('@') != -1 && value.indexOf('.') != -1 && value.length >= 5) {
return true
} else {
return false
}
}
function isString(value, min, max) {
if (typeof value == 'string') {
if (min != undefined) {
if (value.trim().length < min)
return false
}
if (max != undefined) {
if (value.trim().length > max)
return false
}
return true
} else {
return false
}
}
function isBool(value) {
if (typeof value == 'boolean' || value === 1 || value === 0) {
return true
} else {
return false
}
}
function isInt(value) {
if (Number.isInteger(value)) {
return true;
} else {
return false;
}
}
function isArray(value) {
if (Array.isArray(value)) {
return true;
} else {
return false;
}
}
var froncubatorValidator = {
isEmail: isEmail,
isString: isString,
isBool: isBool,
isInt: isInt,
isArray: isArray
}
exports.default = froncubatorValidator;
module.exports = exports['default'];