Skip to content

Commit c3c8179

Browse files
committed
refactor: removed error return parameter from validator service's Email and Birthdate functions
1 parent 0e5cbb4 commit c3c8179

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

struct/mapper/validator/service.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ type (
2626
emailField string,
2727
email string,
2828
validations *govalidatormappervalidation.StructValidations,
29-
) error
29+
)
3030
Birthdate(
3131
birthdateField string,
3232
birthdate *time.Time,
3333
validations *govalidatormappervalidation.StructValidations,
34-
) error
34+
)
3535
CreateValidateFn(
3636
mapper *govalidatormapper.Mapper,
3737
auxiliaryValidatorFns ...interface{},
@@ -101,29 +101,27 @@ func (d *DefaultService) Email(
101101
emailField string,
102102
email string,
103103
validations *govalidatormappervalidation.StructValidations,
104-
) error {
104+
) {
105105
if _, err := govalidatorfieldmail.ValidMailAddress(email); err != nil {
106106
validations.AddFieldValidationError(
107107
emailField,
108108
govalidatorfieldmail.ErrInvalidMailAddress,
109109
)
110110
}
111-
return nil
112111
}
113112

114113
// Birthdate validates the birthdate field
115114
func (d *DefaultService) Birthdate(
116115
birthdateField string,
117116
birthdate *time.Time,
118117
validations *govalidatormappervalidation.StructValidations,
119-
) error {
118+
) {
120119
if birthdate == nil || birthdate.After(time.Now()) {
121120
validations.AddFieldValidationError(
122121
birthdateField,
123122
govalidatorfieldbirthdate.ErrInvalidBirthdate,
124123
)
125124
}
126-
return nil
127125
}
128126

129127
// CreateValidateFn creates a validate function for the request body using the validator

0 commit comments

Comments
 (0)