mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-02 13:44:16 +09: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:
1 parent
8b40df255b
commit
72a9debaff
30 files changed
+331
-737
No files matched your search
@@ -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