-
Notifications
You must be signed in to change notification settings - Fork 0
/
_getExactTypeOfString.js
56 lines (52 loc) · 1.37 KB
/
_getExactTypeOfString.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
import isBlank from './isBlank'
import isBase64 from './isBase64'
import isChinese from './isChinese'
import isEmail from './isEmail'
import isEmpty from './isEmpty'
import isUUID from './isUUID'
import isIPAddress from './isIPAddress'
import isHex from './isHex'
import isHTML from './isHTML'
import isSVG from './isSVG'
import isJSON from './isJSON'
import isTime from './isTime'
/**
* (私有方法)获取确切的字符串类型
* ========================================================================
* @method _getExactTypeOfString
* @private
* @param {String} val - 要检测的字符串
* @returns {String} 返回字符串类型:blank、chinese、email、empty... 等等
*/
const _getExactTypeOfString = (val) => {
let name = 'string'
if (isEmpty(val)) {
name = 'empty'
} else if (isBlank(val)) {
name = 'blank'
} else if (isUUID(val)) {
name = 'guid'
} else if (isBase64(val)) {
name = 'base64'
} else if (isChinese(val)) {
name = 'chinese'
} else if (isEmail(val)) {
name = 'email'
} else if (isIPAddress(val)) {
name = 'IP address'
} else if (isHex(val)) {
name = 'hex'
} else if (isHTML(val)) {
if (isSVG(val)) {
name = 'svg'
} else {
name = 'html'
}
} else if (isJSON(val)) {
name = 'json'
} else if (isTime(val)) {
name = 'time'
}
return name
}
export default _getExactTypeOfString