validator icon indicating copy to clipboard operation
validator copied to clipboard

`excluded_with` doesn't work with structures

Open petitout opened this issue 3 years ago • 4 comments
trafficstars

  • [X] I have looked at the documentation here first?
  • [X] I have looked at the examples provided that may showcase my question here?

Package version eg. v9, v10:

v10

Issue, Question or Enhancement:

excluded_with doesn't work with structures

Code sample, to showcase or reproduce:

type Test2 struct {
	Test2 string
}

type Test struct {
	Fire  *Test2 `validate:"excluded_with=Water"`
	Water *Test2 `validate:"excluded_with=Fire"`
}

func main() {
	data := &Test2{}
	v := validator.New()
	fmt.Println(v.Struct(&Test{Fire: data, Water: data})) 
}

google playground : https://go.dev/play/p/krYBBvE4zWZ

petitout avatar Feb 28 '22 23:02 petitout

Also v curious if there's an answer to this one. @deankarn could you shed any light?

kaifresh avatar Apr 29 '22 01:04 kaifresh

This seems like a bug, I've tested this one too

kevbook avatar Nov 28 '22 14:11 kevbook

Is there any change in this question

StrangeYear avatar Mar 29 '23 14:03 StrangeYear

Same here, and I didn't find any workaround :/

mxmaxime avatar Jun 15 '23 18:06 mxmaxime