mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-04 12:52:28 +08:00
doc: add docment for IsZeroValue function
This commit is contained in:
@@ -493,6 +493,7 @@ import "github.com/duke-git/lancet/v2/validator"
|
||||
- [IsStrongPassword](https://github.com/duke-git/lancet/blob/main/docs/validator.md#IsStrongPassword)
|
||||
- [IsUrl](https://github.com/duke-git/lancet/blob/main/docs/validator.md#IsUrl)
|
||||
- [IsWeakPassword](https://github.com/duke-git/lancet/blob/main/docs/validator.md#IsWeakPassword)
|
||||
- [IsZeroValue](https://github.com/duke-git/lancet/blob/main/docs/validator.md#IsZeroValue)
|
||||
### 19. xerror package implements helpers for errors.
|
||||
|
||||
```go
|
||||
|
||||
@@ -490,6 +490,7 @@ import "github.com/duke-git/lancet/v2/validator"
|
||||
- [IsStrongPassword](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsStrongPassword)
|
||||
- [IsUrl](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsUrl)
|
||||
- [IsWeakPassword](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsWeakPassword)
|
||||
- [IsZeroValue](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsZeroValue)
|
||||
|
||||
### 19. xerror包实现一些错误处理函数
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ import (
|
||||
- [IsStrongPassword](#IsStrongPassword)
|
||||
- [IsUrl](#IsUrl)
|
||||
- [IsWeakPassword](#IsWeakPassword)
|
||||
- [IsZeroValue](#IsZeroValue)
|
||||
|
||||
|
||||
<div STYLE="page-break-after: always;"></div>
|
||||
@@ -765,7 +766,7 @@ func main() {
|
||||
|
||||
|
||||
### <span id="IsWeakPassword">IsWeakPassword</span>
|
||||
<p>Check if the string is weak password(only letter or only number or letter + number)
|
||||
<p>Checks if the string is weak password(only letter or only number or letter + number)
|
||||
.</p>
|
||||
|
||||
<b>Signature:</b>
|
||||
@@ -792,6 +793,36 @@ func main() {
|
||||
|
||||
|
||||
|
||||
### <span id="IsZeroValue">IsZeroValue</span>
|
||||
<p>Checks if passed value is a zero value.</p>
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```go
|
||||
func IsZeroValue(value any) bool
|
||||
```
|
||||
<b>Example:</b>
|
||||
|
||||
```go
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/duke-git/lancet/v2/validator"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(validator.IsZeroValue(nil)) //true
|
||||
fmt.Println(validator.IsZeroValue(0)) //true
|
||||
fmt.Println(validator.IsZeroValue("")) //true
|
||||
fmt.Println(validator.IsZeroValue([]int)) //true
|
||||
fmt.Println(validator.IsZeroValue(interface{})) //true
|
||||
|
||||
fmt.Println(validator.IsZeroValue("0")) //false
|
||||
fmt.Println(validator.IsZeroValue("nil")) //false
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ import (
|
||||
- [IsStrongPassword](#IsStrongPassword)
|
||||
- [IsUrl](#IsUrl)
|
||||
- [IsWeakPassword](#IsWeakPassword)
|
||||
- [IsZeroValue](#IsZeroValue)
|
||||
|
||||
|
||||
<div STYLE="page-break-after: always;"></div>
|
||||
@@ -792,8 +793,31 @@ func main() {
|
||||
|
||||
|
||||
|
||||
### <span id="IsZeroValue">IsZeroValue</span>
|
||||
<p>判断传入的参数值是否为零值</p>
|
||||
|
||||
<b>函数签名:</b>
|
||||
|
||||
```go
|
||||
func IsZeroValue(value any) bool
|
||||
```
|
||||
<b>例子:</b>
|
||||
|
||||
```go
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/duke-git/lancet/v2/validator"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(validator.IsZeroValue(nil)) //true
|
||||
fmt.Println(validator.IsZeroValue(0)) //true
|
||||
fmt.Println(validator.IsZeroValue("")) //true
|
||||
fmt.Println(validator.IsZeroValue([]int)) //true
|
||||
fmt.Println(validator.IsZeroValue(interface{})) //true
|
||||
|
||||
fmt.Println(validator.IsZeroValue("0")) //false
|
||||
fmt.Println(validator.IsZeroValue("nil")) //false
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user