Skip to content

Commit

Permalink
Merge pull request #4 from imanborumand/fix-validation-condition
Browse files Browse the repository at this point in the history
Fix validation condition for struct pointer
  • Loading branch information
behzadsh authored Nov 2, 2024
2 parents c64842f + 45a4dd6 commit 6ad9da1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func ValidateStruct(input any, rulesMap RulesMap, locale ...string) Result {
}

v := reflect.ValueOf(input)
if v.Kind() != reflect.Struct || (v.Kind() == reflect.Ptr && v.Elem().Kind() == reflect.Struct) {
if v.Kind() != reflect.Struct && !(v.Kind() == reflect.Ptr && v.Elem().Kind() == reflect.Struct) {
panic("validation.ValidateStruct only support struct or a pointer to a struct as first parameter")
}

Expand Down

0 comments on commit 6ad9da1

Please sign in to comment.