Skip to content

Commit

Permalink
update some code format
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Dec 17, 2019
1 parent c24761d commit 5b2da9b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ type GlobalOption struct {
`required_with` | `required_with:foo,bar,...` 在其他任一指定字段出现时,验证的字段才必须存在且不为空
`required_with_all` | `required_with_all:foo,bar,...` 只有在其他指定字段全部出现时,验证的字段才必须存在且不为空
`required_without` | `required_without:foo,bar,...` 在其他指定任一字段不出现时,验证的字段才必须存在且不为空
`required_without_all` | `required_without_all:foo,bar,...`只有在其他指定字段全部不出现时,验证的字段才必须存在且不为空
`required_without_all` | `required_without_all:foo,bar,...` 只有在其他指定字段全部不出现时,验证的字段才必须存在且不为空
`-/safe` | 标记当前字段是安全的,无需验证
`int/integer/isInt` | 检查值是 `intX` `uintX` 类型
`uint/isUint` | 检查值是 `uintX` 类型(`value >= 0`
Expand Down
2 changes: 1 addition & 1 deletion messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func (t *Translator) Message(validator, field string, args ...interface{}) (msg
msg = strings.Replace(msg, "{args}", args, 1)
}

return strings.Split(msg, "%!(EXTRA")[0] //todo gracefully avoid exceptions when formatting strings
return strings.Split(msg, "%!(EXTRA")[0] // todo gracefully avoid exceptions when formatting strings
}

// format message for the validator
Expand Down
2 changes: 2 additions & 0 deletions validate_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package validate

import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -94,6 +95,7 @@ func TestValidation_RequiredWithAll(t *testing.T) {
})

v.Validate()
fmt.Println(v.Errors)
assert.Equal(t, v.Errors.One(), "nothing field is required when [age name sex] is present")
}

Expand Down
10 changes: 5 additions & 5 deletions validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func (v *Validation) Required(field string, val interface{}) bool {
return !IsEmpty(val)
}

// RequiredIf field under validation must be present and not empty if the anotherfield field is equal to any value.
// RequiredIf field under validation must be present and not empty if the anotherField field is equal to any value.
func (v *Validation) RequiredIf(field string, val interface{}, kvs ...string) bool {
// format error
if len(kvs) < 2 {
Expand All @@ -289,8 +289,8 @@ func (v *Validation) RequiredIf(field string, val interface{}, kvs ...string) bo
return true
}

// RequiredUnless field under validation must be present and not empty unless the anotherfield field is equal to any value.
func (v *Validation) RequiredUnless(field string, val interface{}, kvs ...string) bool {
// RequiredUnless field under validation must be present and not empty unless the anotherField field is equal to any value.
func (v *Validation) RequiredUnless(_ string, val interface{}, kvs ...string) bool {
// format error
if len(kvs) < 2 {
return false
Expand All @@ -309,7 +309,7 @@ func (v *Validation) RequiredUnless(field string, val interface{}, kvs ...string
}

// RequiredWith field under validation must be present and not empty only if any of the other specified fields are present.
func (v *Validation) RequiredWith(field string, val interface{}, kvs ...string) bool {
func (v *Validation) RequiredWith(_ string, val interface{}, kvs ...string) bool {
// format error
if len(kvs) == 0 {
return false
Expand All @@ -326,7 +326,7 @@ func (v *Validation) RequiredWith(field string, val interface{}, kvs ...string)
}

// RequiredWithAll field under validation must be present and not empty only if all of the other specified fields are present.
func (v *Validation) RequiredWithAll(field string, val interface{}, kvs ...string) bool {
func (v *Validation) RequiredWithAll(_ string, val interface{}, kvs ...string) bool {
// format error
if len(kvs) == 0 {
return false
Expand Down

0 comments on commit 5b2da9b

Please sign in to comment.