ValidateMathTransform validates a MathTransform.
(m *v1beta1.MathTransform)
| 287 | |
| 288 | // ValidateMathTransform validates a MathTransform. |
| 289 | func ValidateMathTransform(m *v1beta1.MathTransform) *field.Error { |
| 290 | if m.Type == "" { |
| 291 | return field.Required(field.NewPath("type"), "math transform type is required") |
| 292 | } |
| 293 | switch m.Type { |
| 294 | case v1beta1.MathTransformTypeMultiply: |
| 295 | if m.Multiply == nil { |
| 296 | return field.Required(field.NewPath("multiply"), "must specify a value if a multiply math transform is specified") |
| 297 | } |
| 298 | case v1beta1.MathTransformTypeClampMin: |
| 299 | if m.ClampMin == nil { |
| 300 | return field.Required(field.NewPath("clampMin"), "must specify a value if a clamp min math transform is specified") |
| 301 | } |
| 302 | case v1beta1.MathTransformTypeClampMax: |
| 303 | if m.ClampMax == nil { |
| 304 | return field.Required(field.NewPath("clampMax"), "must specify a value if a clamp max math transform is specified") |
| 305 | } |
| 306 | default: |
| 307 | return field.Invalid(field.NewPath("type"), m.Type, "unknown math transform type") |
| 308 | } |
| 309 | return nil |
| 310 | } |
| 311 | |
| 312 | // ValidateMapTransform validates MapTransform. |
| 313 | func ValidateMapTransform(m *v1beta1.MapTransform) *field.Error { |
no outgoing calls
no test coverage detected