-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replacing github.com/xeipuuv/gojsonschema with github.com/santhosh-te…
…kuri because it seems that the former hasn't been maintained. Also fixing a bug in fallbackregistry (added a test) in which the last loader would've been picked up instead of the former. #15
- Loading branch information
1 parent
f05547a
commit 5f02d45
Showing
503 changed files
with
10,509 additions
and
7,667 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,16 @@ | ||
package validator | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/xeipuuv/gojsonschema" | ||
"github.com/santhosh-tekuri/jsonschema" | ||
) | ||
|
||
// jsonSchemaValidator is a validator backed by JSONSchema parsing and validation. | ||
type jsonSchema struct { | ||
schema *gojsonschema.Schema | ||
errors []error | ||
schema *jsonschema.Schema | ||
} | ||
|
||
// IsValid checks the passed-in descriptor against the JSONSchema. If it returns | ||
// false, erros can be checked calling Errors() method. | ||
func (v *jsonSchema) IsValid(descriptor map[string]interface{}) bool { | ||
v.errors = nil | ||
result, err := v.schema.Validate(gojsonschema.NewGoLoader(descriptor)) | ||
if err != nil { | ||
v.errors = append(v.errors, err) | ||
return false | ||
} | ||
for _, desc := range result.Errors() { | ||
v.errors = append(v.errors, fmt.Errorf(desc.String())) | ||
} | ||
return len(v.errors) == 0 | ||
} | ||
|
||
// Errors returns the errors found at the last call of IsValid, if any. | ||
func (v *jsonSchema) Errors() []error { | ||
return v.errors | ||
func (v *jsonSchema) Validate(descriptor map[string]interface{}) error { | ||
return v.schema.ValidateInterface(descriptor) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.