ValidateCombine validates a Combine.
(c *v1beta1.Combine)
| 223 | |
| 224 | // ValidateCombine validates a Combine. |
| 225 | func ValidateCombine(c *v1beta1.Combine) *field.Error { |
| 226 | switch c.Strategy { |
| 227 | case v1beta1.CombineStrategyString: |
| 228 | if c.String == nil { |
| 229 | return field.Required(field.NewPath("string"), fmt.Sprintf("string must be set for combine strategy %s", c.Strategy)) |
| 230 | } |
| 231 | case "": |
| 232 | return field.Required(field.NewPath("strategy"), "a combine strategy must be provided") |
| 233 | default: |
| 234 | return field.Invalid(field.NewPath("strategy"), c.Strategy, "unknown strategy type") |
| 235 | } |
| 236 | |
| 237 | if len(c.Variables) == 0 { |
| 238 | return field.Required(field.NewPath("variables"), "at least one variable must be provided") |
| 239 | } |
| 240 | |
| 241 | for i := range c.Variables { |
| 242 | if c.Variables[i].FromFieldPath == "" { |
| 243 | return field.Required(field.NewPath("variables").Index(i).Child("fromFieldPath"), "fromFieldPath must be set for each combine variable") |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | return nil |
| 248 | } |
| 249 | |
| 250 | // ValidateTransform validates a Transform. |
| 251 | func ValidateTransform(t v1beta1.Transform) *field.Error { //nolint:gocyclo // This is a long but simple/same-y switch. |
no outgoing calls