Skip to content

Commit

Permalink
style: format codes
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jan 8, 2021
1 parent 84026e0 commit 6e2dacb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions issues_test.go
Expand Up @@ -177,7 +177,7 @@ func TestIssues34(t *testing.T) {

dump.Println(Enum(s1, []int{1, 2, 3, 4}), Enum(int32(s1), []int{1, 2, 3, 4}))

assert.True(t,v.Validate())
assert.True(t, v.Validate())
dump.Println(v.Errors)

type someMode string
Expand All @@ -188,7 +188,7 @@ func TestIssues34(t *testing.T) {
v.StringRules(MS{
"mode": "required|in:abc,def",
})
assert.True(t,v.Validate())
assert.True(t, v.Validate())

dump.Println(v.Errors)
}
Expand Down
2 changes: 1 addition & 1 deletion register.go
Expand Up @@ -209,7 +209,7 @@ var validatorAliases = map[string]string{
"strint": "isIntString",
"strInt": "isIntString",
"str_int": "isIntString",
"intstr": "isIntString",
"intstr": "isIntString",
"intString": "isIntString",
"int_string": "isIntString",
// ---
Expand Down
8 changes: 4 additions & 4 deletions validators.go
Expand Up @@ -1099,16 +1099,16 @@ func Between(val interface{}, min, max int64) bool {
*************************************************************/

// convert custom type to int or string or unit
func convert(val interface{})(value interface{},err error) {
func convert(val interface{}) (value interface{}, err error) {

v := reflect.ValueOf(val)

switch v.Kind() {
case reflect.String:
value = v.String()
case reflect.Int,reflect.Int8,reflect.Int16,reflect.Int32,reflect.Int64:
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
value = v.Int()
case reflect.Uint,reflect.Uint8,reflect.Uint16,reflect.Uint32,reflect.Uint64:
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
value = v.Uint()
default:
err = errConvertFail
Expand All @@ -1123,7 +1123,7 @@ func Enum(val, enum interface{}) bool {
return false
}

v,err := convert(val)
v, err := convert(val)
if err != nil {
return false
}
Expand Down

0 comments on commit 6e2dacb

Please sign in to comment.