Reworked Required and OmitEmpty #8
Merged
lunny
merged 4 commits from KN4CK3R/binding:feature-ignore-empty
into master
2 years ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'KN4CK3R/binding:feature-ignore-empty'
Deleting a branch is permanent. It CANNOT be undone. Continue?
The old behaviour is inconsistent because this fails:
Here you need
OmitEmpty
even if the field is not required.The new logic:
In short: Rules are skipped if a field is empty and not required. Thats the normal behaviour in other validation libraries like Yup too.
After this change there are some places in Gitea where we can add form validation to optional fields which is not possible at the moment. Possible changes in:
21465a2ce3/modules/structs/admin_user.go (L31)
21465a2ce3/modules/structs/admin_user.go (L35)
21465a2ce3/modules/structs/org_team.go (L38)
21465a2ce3/modules/validation/binding.go (L90)
21465a2ce3/modules/validation/binding.go (L108)
Please resolve the conflicts.
I see no conflicts? There was a conflict which should be resolved with the merge of the master branch some hours ago.
It maybe a bug of Gitea, when update, it displays below error.
@KN4CK3R can you rebase or update this pull please?
b29e041704
into master 2 years agoReviewers
b29e041704
.