xuruiqian
2025-06-04 17ce21955b4e3402d3d5868b52e50bfdd55bc572
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
'use strict';
 
class Validator {
    constructor(arg) {
 
    }
 
    checkEmpty(val) {
        if (typeof val === 'boolean') {
            return false
        }
        if (typeof val === 'number') {
            return false
        }
        if (val instanceof Array) {
            if (val.length === 0) return true
        } else if (val instanceof Object) {
            if (JSON.stringify(val) === '{}') return true
        } else {
            if (val === 'null' || val == null || val === 'undefined' || val === undefined || val === '') return true
            return false
        }
        return false
    }
 
    checkEmail(email) {
        return RegExp(
                /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/)
            .test(
                email);
    }
 
    checkMobile(mobile) {
        return RegExp(/^1[34578]\d{9}$/).test(mobile);
    }
 
    checkMobile2(mobile) {
        if (!/(^1[0-9][0-9]{9}$)/.test(mobile)) {
            return false;
        }
 
        return true;
    }
}
 
export default new Validator()