-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathempty_check_builtin.go
65 lines (57 loc) · 1.45 KB
/
empty_check_builtin.go
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
package dyntpl
// EmptyCheckInt checks is val is an empty integer.
func EmptyCheckInt(_ *Ctx, val any) bool {
if i, ok := ConvInt(val); ok && i == 0 {
return true
}
return false
}
// EmptyCheckUint checks is val is an empty unsigned integer.
func EmptyCheckUint(_ *Ctx, val any) bool {
if u, ok := ConvUint(val); ok && u == 0 {
return true
}
return false
}
// EmptyCheckFloat checks is val is an empty float number.
func EmptyCheckFloat(_ *Ctx, val any) bool {
if f, ok := ConvFloat(val); ok && f == 0 {
return true
}
return false
}
// EmptyCheckBytes checks is val is an empty bytes array.
func EmptyCheckBytes(_ *Ctx, val any) bool {
if b, ok := ConvBytes(val); ok && len(b) == 0 {
return true
}
return false
}
// EmptyCheckBytesSlice checks is val is an empty slice of bytes.
func EmptyCheckBytesSlice(_ *Ctx, val any) bool {
if b, ok := ConvBytesSlice(val); ok && len(b) == 0 {
return true
}
return false
}
// EmptyCheckStr checks is val is an empty string.
func EmptyCheckStr(_ *Ctx, val any) bool {
if s, ok := ConvStr(val); ok && len(s) == 0 {
return true
}
return false
}
// EmptyCheckStrSlice checks is val is an empty slice of strings.
func EmptyCheckStrSlice(_ *Ctx, val any) bool {
if s, ok := ConvStrSlice(val); ok && len(s) == 0 {
return true
}
return false
}
// EmptyCheckBool checks is val is an empty bool.
func EmptyCheckBool(_ *Ctx, val any) bool {
if b, ok := ConvBool(val); ok && !b {
return true
}
return false
}