Add support for non-struct pointers #5
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "KN4CK3R/binding:feature-pointer"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR adds support for pointers to optional fields in forms.
This example fails in the old version:
The empty
Test
field is no problem because an empty field is valid url. The empty pointer field throws an error because the regex checks against the wrong field value of"0xc000011dc0"
. So the memory address is formatted as string and tested. After the change both fields pass because both are treated equal.Fixes the workaround in https://github.com/go-gitea/gitea/pull/15690
@ -353,7 +353,22 @@ func validateStruct(errors Errors, obj interface{}) Errors {
(field.Type.Kind() == reflect.Ptr && !reflect.DeepEqual(zero, fieldValue) &&
field.Type.Elem().Kind() == reflect.Struct) {
errors = validateStruct(errors, fieldValue)
continue
I'm not sure about the
continue
but I think it's right.WIP: Add support for non-struct pointersto Add support for non-struct pointersfiles conflicted.
Please resolve the conflicts.
@KN4CK3R ?