Skip to content

Commit

Permalink
chore: implement error interface with the ValidationError struct (#23)
Browse files Browse the repository at this point in the history
Signed-off-by: Armando Ruocco <[email protected]>
  • Loading branch information
armru authored Feb 19, 2024
1 parent af27643 commit fc2c761
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pkg/operator/extensions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package operator

import (
"fmt"
"strings"
)

type ValidationErrors []ValidationError

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,
)
}

0 comments on commit fc2c761

Please sign in to comment.