@@ -97,10 +97,12 @@ func (requirednessTagValidator) doRequired(context Context) (Validations, error)
97
97
case types .Pointer :
98
98
return Validations {Functions : []FunctionGen {Function (requiredTagName , ShortCircuit , requiredPointerValidator )}}, nil
99
99
case types .Struct :
100
- // The +required tag on a non-pointer struct is only for documentation.
101
- // We don't perform validation here and defer the validation to
102
- // the struct's fields.
103
- return Validations {Comments : []string {"required non-pointer structs are purely documentation" }}, nil
100
+ // The +k8s:required tag on a non-pointer struct is not supported.
101
+ // If you encounter this error and believe you have a valid use case
102
+ // for forbiddening a non-pointer struct, please let us know! We need
103
+ // to understand your scenario to determine if we need to adjust
104
+ // this behavior or provide alternative validation mechanisms.
105
+ return Validations {}, fmt .Errorf ("non-pointer structs cannot use the %q tag" , requiredTagName )
104
106
}
105
107
return Validations {Functions : []FunctionGen {Function (requiredTagName , ShortCircuit , requiredValueValidator )}}, nil
106
108
}
@@ -125,11 +127,12 @@ func (requirednessTagValidator) doOptional(context Context) (Validations, error)
125
127
case types .Pointer :
126
128
return Validations {Functions : []FunctionGen {Function (optionalTagName , ShortCircuit | NonError , optionalPointerValidator )}}, nil
127
129
case types .Struct :
128
- // Specifying that a non-pointer struct is optional doesn't actually
129
- // make sense technically almost ever, and is better described as a
130
- // union inside the struct. It does, however, make sense as
131
- // documentation.
132
- return Validations {Comments : []string {"optional non-pointer structs are purely documentation" }}, nil
130
+ // The +k8s:optional tag on a non-pointer struct is not supported.
131
+ // If you encounter this error and believe you have a valid use case
132
+ // for forbiddening a non-pointer struct, please let us know! We need
133
+ // to understand your scenario to determine if we need to adjust
134
+ // this behavior or provide alternative validation mechanisms.
135
+ return Validations {}, fmt .Errorf ("non-pointer structs cannot use the %q tag" , optionalTagName )
133
136
}
134
137
return Validations {Functions : []FunctionGen {Function (optionalTagName , ShortCircuit | NonError , optionalValueValidator )}}, nil
135
138
}
@@ -174,7 +177,7 @@ func (requirednessTagValidator) doForbidden(context Context) (Validations, error
174
177
},
175
178
}, nil
176
179
case types .Struct :
177
- // The +forbidden tag on a non-pointer struct is not supported.
180
+ // The +k8s: forbidden tag on a non-pointer struct is not supported.
178
181
// If you encounter this error and believe you have a valid use case
179
182
// for forbiddening a non-pointer struct, please let us know! We need
180
183
// to understand your scenario to determine if we need to adjust
0 commit comments