MCPcopy Create free account
hub / github.com/crossplane-contrib/function-patch-and-transform / ValidateMathTransform

Function ValidateMathTransform

validate.go:289–310  ·  view source on GitHub ↗

ValidateMathTransform validates a MathTransform.

(m *v1beta1.MathTransform)

Source from the content-addressed store, hash-verified

287
288// ValidateMathTransform validates a MathTransform.
289func 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.
313func ValidateMapTransform(m *v1beta1.MapTransform) *field.Error {

Callers 2

ValidateTransformFunction · 0.85
ResolveMathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected