Skip to content

Commit

Permalink
fix: ValidationError as value (#16)
Browse files Browse the repository at this point in the history
Signed-off-by: Alfredo Garo <[email protected]>
  • Loading branch information
garomonegro authored Feb 1, 2022
1 parent 58589d1 commit 25fe93e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ The `error` returned by `Validate()` has structured data with information on the
``` golang
v := validator.NewValidator(client, spec)
err := v.Validate()
if vErr, ok := err.(*validator.ValidationError); ok {
if vErr, ok := err.(validator.ValidationError); ok {

fmt.Printf("Validation failed for %s/%s/%s.\n",
vErr.GVR.Group, vErr.GVR.Version, vErr.GVR.Resource)
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ type ValidationError struct {
ConditionValidations []ConditionValidationResult
}

func (e *ValidationError) Error() string {
func (e ValidationError) Error() string {
fieldValidationResult, _ := json.MarshalIndent(e.FieldValidations, "", "\t")
conditionValidationResult, _ := json.MarshalIndent(e.ConditionValidations, "", "\t")
return fmt.Sprintf("%v.\nGVR: %s/%s/%s.\nField Validation Results: %s\nCondition Validation Results: %s", e.Message,
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (v *Validator) Validate() error {
prettyPrintStruct(summary)
}
if r.Required {
v.Waiter.errors <- &ValidationError{
v.Waiter.errors <- ValidationError{
Message: errors.Errorf("failure threshold met for resource '%v'", resourceName),
GVR: groupVersionResource(r.APIVersion, r.Name),
FieldValidations: summary.FieldValidation,
Expand Down

0 comments on commit 25fe93e

Please sign in to comment.