Skip to content

Add the validate function#203

Open
jdesrosiers wants to merge 2 commits intomainfrom
evaluation-plugin
Open

Add the validate function#203
jdesrosiers wants to merge 2 commits intomainfrom
evaluation-plugin

Conversation

@jdesrosiers
Copy link
Copy Markdown
Collaborator

@hyperjump/json-schema allows you to compile a schema once and validate many instances against that compiled schema. But, since converting from standard output to normalized output uses the compiled schema we still end up recompiling for every validation when using this package.

This PR adds a validate function that allows you to compile and validate returning the enhanced messaging provided by this package without needing to recompile with every validation. It does this by using an EvaluationPlugin to produce output directly in the normalized format skipping the need to convert between formats.

Ideally, this function would be added to @hyperjump/json-schema instead of here, but it doesn't quite fit that API because getErrors is async. So, I'm putting it here for now and maybe at some point we'll figure out a way to move it over where it belongs.

@srivastava-diya
Copy link
Copy Markdown
Contributor

Hey @jdesrosiers , I noticed this PR adding the validate function and EvaluationPlugin. I'm actually studying this PR right now to use it in the lsp project (replace vscode-json-languageservice) It’s a perfect example of how to build the MatchingSchemaCollector I need using the plugin system. If you plan to merge this there, I'll probably also use the new validate function directly in the language server to power the validation diagnostics.

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

Successfully merging this pull request may close these issues.

2 participants