Skip to content

Commit 750f72e

Browse files
Jamie Tannajamietanna
authored andcommitted
refactor: return early if no options
As it simplifies the readability of the checks.
1 parent 83a8756 commit 750f72e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

oapi_validate.go

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

79-
if options != nil && options.ErrorHandler != nil {
80-
options.ErrorHandler(w, err.Error(), statusCode)
81-
} else {
79+
if options == nil {
8280
http.Error(w, err.Error(), statusCode)
81+
return
82+
}
83+
84+
if options.ErrorHandler != nil {
85+
options.ErrorHandler(w, err.Error(), statusCode)
8386
}
8487
})
8588
}

0 commit comments

Comments
 (0)