Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ func (v *validate) traverseField(ctx context.Context, parent reflect.Value, curr
}
}

if kind == reflect.Invalid {
return
}

case reflect.Struct:
isNestedStruct = !current.Type().ConvertibleTo(timeType)
// For backward compatibility before struct level validation tags were supported
Expand Down
7 changes: 7 additions & 0 deletions validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2317,6 +2317,13 @@ func TestSQLValueValidation(t *testing.T) {
Equal(t, len(errs.(ValidationErrors)), 2)
AssertError(t, errs, "CustomMadeUpStruct.MadeUp", "CustomMadeUpStruct.MadeUp", "MadeUp", "MadeUp", "required")
AssertError(t, errs, "CustomMadeUpStruct.OverriddenInt", "CustomMadeUpStruct.OverriddenInt", "OverriddenInt", "OverriddenInt", "gt")

// Test for empty field on structs without tags
type InvalidValuePanicSafetyTest struct {
V valuer
}
errs = validate.Struct(InvalidValuePanicSafetyTest{})
Equal(t, errs, nil)
}

func TestMACValidation(t *testing.T) {
Expand Down