Try migrating to new JSON validation library

This commit is contained in:
Yann Hamon 2023-01-22 18:22:39 +01:00
parent ba844cad0a
commit 5f9df6d080
2 changed files with 2 additions and 3 deletions

View file

@ -180,8 +180,7 @@ func (val *v) ValidateResource(res resource.Resource) Result {
err = schema.Validate(r)
if err != nil {
// This error can only happen if the Object to validate is poorly formed. There's no hope of saving this one
return Result{Resource: res, Status: Error, Err: fmt.Errorf("problem validating schema. Check JSON formatting: %s", err)}
return Result{Resource: res, Status: Invalid, Err: fmt.Errorf("problem validating schema. Check JSON formatting: %s", err)}
}
return Result{Resource: res, Status: Valid}

View file

@ -372,7 +372,7 @@ lastName: bar
}
if got := val.ValidateResource(resource.Resource{Bytes: testCase.rawResource}); got.Status != testCase.expect {
if got.Err != nil {
t.Errorf("%d - expected %d, got %d: %s", i, testCase.expect, got.Status, got.Err.Error())
t.Errorf("Test '%s' - expected %d, got %d: %s", testCase.name, testCase.expect, got.Status, got.Err.Error())
} else {
t.Errorf("%d - expected %d, got %d", i, testCase.expect, got.Status)
}