mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-16 07:34:53 +00:00
refactor: clean up form binding & validation (#38873)
Clarify the "validation" and "error display" logic. All the copied&pasted `Validate` functions are removed.
This commit is contained in:
@@ -37,13 +37,7 @@ func performValidationTest(t *testing.T, testCase validationTestCase) {
|
||||
m := chi.NewRouter()
|
||||
|
||||
m.Post(testRoute, func(resp http.ResponseWriter, req *http.Request) {
|
||||
actual := binding.Validate(req, testCase.data)
|
||||
// see https://github.com/stretchr/testify/issues/435
|
||||
if actual == nil {
|
||||
actual = binding.Errors{}
|
||||
}
|
||||
|
||||
assert.Equal(t, testCase.expectedErrors, actual)
|
||||
assert.Equal(t, testCase.expectedErrors, binding.Validate(req, testCase.data))
|
||||
})
|
||||
|
||||
req, err := http.NewRequest(http.MethodPost, testRoute, nil)
|
||||
|
||||
Reference in New Issue
Block a user