diff --git a/pkg/operator/extensions.go b/pkg/operator/extensions.go new file mode 100644 index 0000000..087a550 --- /dev/null +++ b/pkg/operator/extensions.go @@ -0,0 +1,33 @@ +package operator + +import ( + "fmt" + "strings" +) + +type ValidationErrors []ValidationError + +// ContainsErrors returns true if the slice contains any ValidationError +func (v ValidationErrors) ContainsErrors() bool { + return len(v) > 0 +} + +func (v ValidationErrors) Error() string { + messages := make([]string, len(v)) + + for idx := range v { + validationError := &v[idx] + messages[idx] = validationError.Error() + } + + return strings.Join(messages, ";") +} + +func (v *ValidationError) Error() string { + return fmt.Sprintf( + "encountered a validation error, message: %s, value: %s, pathComponents: %s", + v.Message, + v.Value, + v.PathComponents, + ) +}