Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Validation not working #345

Open
ciolo opened this issue Feb 25, 2022 · 1 comment
Open

[BUG] Validation not working #345

ciolo opened this issue Feb 25, 2022 · 1 comment

Comments

@ciolo
Copy link

ciolo commented Feb 25, 2022

Hi,
Maybe I got the configuration wrong, but following the examples in the README the validation doesn't work correctly. In detail:

documentLoader := gojsonschema.NewGoLoader(feed)
schemaLoader := gojsonschema.NewGoLoader(v.Schema)
result, err := gojsonschema.Validate(schemaLoader, documentLoader)

feed and v.Schema they could be anything and validation returns no errors. Why? Can you help me plz?

Thanks.

@dadav
Copy link

dadav commented Sep 8, 2023

I'm also experiencing something like this. In my case I'm doing it like this:

	sl := gojsonschema.NewSchemaLoader()
	sl.Validate = true

	if err := sl.AddSchemas(gojsonschema.NewStringLoader(string(jsonStr))); err != nil {
		return err
	}

I was expecting that this would return an error if someone would use for example type: foobar in their jsonschema. But nothing happens...no errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants