Skip to content

Commit b73ed97

Browse files
author
Jamie Tanna
committed
refactor: return early if no options
As it simplifies the readability of the checks.
1 parent 8abc058 commit b73ed97

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

oapi_validate.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,13 @@ func OapiRequestValidatorWithOptions(spec *openapi3.T, options *Options) func(ne
7070
return
7171
}
7272

73-
if options != nil && options.ErrorHandler != nil {
74-
options.ErrorHandler(w, err.Error(), statusCode)
75-
} else {
73+
if options == nil {
7674
http.Error(w, err.Error(), statusCode)
75+
return
76+
}
77+
78+
if options.ErrorHandler != nil {
79+
options.ErrorHandler(w, err.Error(), statusCode)
7780
}
7881
})
7982
}

0 commit comments

Comments
 (0)