Skip to content

Commit

Permalink
change type checking to compatible in library
Browse files Browse the repository at this point in the history
  • Loading branch information
dbadura authored and johandorland committed Sep 12, 2019
1 parent e016113 commit 848af29
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions draft.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,18 @@ func parseSchemaURL(documentNode interface{}) (string, *Draft, error) {
if isKind(documentNode, reflect.Bool) {
return "", nil, nil
}
m, ok := documentNode.(map[string]interface{})
if !ok {
return "", nil, errors.New("schema is not valid")

if !isKind(documentNode, reflect.Map) {
return "", nil, errors.New(formatErrorDescription(
Locale.ParseError(),
ErrorDetails{
"expected": STRING_SCHEMA,
},
))
}

m := documentNode.(map[string]interface{})

if existsMapKey(m, KEY_SCHEMA) {
if !isKind(m[KEY_SCHEMA], reflect.String) {
return "", nil, errors.New(formatErrorDescription(
Expand Down
2 changes: 1 addition & 1 deletion schemaLoader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,5 @@ func TestParseSchemaURL_NotMap(t *testing.T) {
_, err := NewSchema(sl)
//THEN
require.Error(t, err)
assert.EqualError(t, err, "schema is not valid")
assert.EqualError(t, err, "Expected: valid schema, given: Invalid JSON")
}

0 comments on commit 848af29

Please sign in to comment.