Skip to content

Commit 0e5cbb4

Browse files
committed
test: set the auxiliary validator function as a variadic parameter
1 parent b1a5b1f commit 0e5cbb4

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

struct/mapper/validator/service.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type (
3434
) error
3535
CreateValidateFn(
3636
mapper *govalidatormapper.Mapper,
37-
auxiliaryValidatorFn interface{},
37+
auxiliaryValidatorFns ...interface{},
3838
) (
3939
func(
4040
dest interface{},
@@ -134,7 +134,7 @@ func (d *DefaultService) Birthdate(
134134
// func(dest *RequestType, validations *govalidatormappervalidation.StructValidations) error
135135
func (d *DefaultService) CreateValidateFn(
136136
mapper *govalidatormapper.Mapper,
137-
auxiliaryValidatorFn interface{},
137+
auxiliaryValidatorFns ...interface{},
138138
) (
139139
func(
140140
dest interface{},
@@ -174,13 +174,15 @@ func (d *DefaultService) CreateValidateFn(
174174
}
175175

176176
// Call the validate function
177-
_, err = goreflect.SafeCallFunction(
178-
auxiliaryValidatorFn,
179-
dest,
180-
rootStructValidations,
181-
)
182-
if err != nil {
183-
panic(err)
177+
for _, auxiliaryValidatorFn := range auxiliaryValidatorFns {
178+
_, err = goreflect.SafeCallFunction(
179+
auxiliaryValidatorFn,
180+
dest,
181+
rootStructValidations,
182+
)
183+
if err != nil {
184+
panic(err)
185+
}
184186
}
185187

186188
// Parse the validations

0 commit comments

Comments
 (0)