diff --git a/jsonLoader.go b/jsonLoader.go index 9433f3e..842cdf4 100644 --- a/jsonLoader.go +++ b/jsonLoader.go @@ -334,6 +334,12 @@ func decodeJsonUsingNumber(r io.Reader) (interface{}, error) { if err != nil { return nil, err } + _, isSlice := document.([]interface{}) + _, isMap := document.(map[string]interface{}) + + if !isSlice && !isMap { + return nil, fmt.Errorf("Parse Error:Invalid JSON") + } return document, nil diff --git a/locales.go b/locales.go index c530952..b087aeb 100644 --- a/locales.go +++ b/locales.go @@ -249,7 +249,7 @@ func (l DefaultLocale) ReferenceMustBeCanonical() string { } func (l DefaultLocale) NotAValidType() string { - return `{{.type}} is not a valid type -- ` + return `has a primitive type that is NOT VALID -- given: {{.given}} Expected valid values are:{{.expected}}` } func (l DefaultLocale) Duplicated() string { diff --git a/schemaType.go b/schemaType.go index e13a0fb..36b447a 100644 --- a/schemaType.go +++ b/schemaType.go @@ -44,7 +44,7 @@ func (t *jsonSchemaType) IsTyped() bool { func (t *jsonSchemaType) Add(etype string) error { if !isStringInSlice(JSON_TYPES, etype) { - return errors.New(formatErrorDescription(Locale.NotAValidType(), ErrorDetails{"type": etype})) + return errors.New(formatErrorDescription(Locale.NotAValidType(), ErrorDetails{"given": "/" + etype + "/", "expected": JSON_TYPES})) } if t.Contains(etype) {