getting error 'Invalid field namespace' when using required_without tag in ValidateMap (go-playground validator)

49 Views Asked by At

I have a map that looks like this:

m := map[string]interface{}{
"config_v1" : "...",
"config_v2" : "...",
}

and I want to add the rules :

  • config_v1 must exists if config_v2 doesn't
  • config_v2 must exists if config_v1 doesn't

the rules I added are:

rules := map[string]interface{}{
"config_v1" : "required_without=config_v2",
"config_v2" : "required_without=config_v1",
}

but when I call ValidateMap(options, rules) I get this error: 'Invalid field namespace'

Is there anything I'm doing wrong? Thanks!

0

There are 0 best solutions below