orchestrator/clickhouse: fix Networks field validation

This commit is contained in:
Vincent Bernat
2022-08-24 10:10:22 +02:00
parent 743c98a78f
commit e93b57034c
3 changed files with 7 additions and 3 deletions

View File

@@ -20,7 +20,10 @@ var Validate *validator.Validate
func RegisterSubnetMapValidation[V any]() {
var zero SubnetMap[V]
validatorFunc := func(field reflect.Value) interface{} {
if subnetMap, ok := field.Interface().(SubnetMap[V]); ok {
switch subnetMap := field.Interface().(type) {
case SubnetMap[V]:
return subnetMap.ToMap()
case *SubnetMap[V]:
return subnetMap.ToMap()
}
return nil