Jsoneditor: onError function doesn't get invoked

Created on 7 Jun 2016  路  2Comments  路  Source: josdejong/jsoneditor

onError function passed as an option into the JSONEditor doesn't get invoked when the JSON doesn't meet the schema requirements. Would there be anything you would recommend?

Thanks.

Most helpful comment

Makes sense to me to create a neat public API to check the validity against the configured schema.

+1

All 2 comments

That's an interesting one. Currently errors are only thrown when the document contains invalid JSON but doesn't reckon with a JSON schema. A JSON Schema will only result in warnings being displayed to the user.

If you want to force a user to have JSON conform a JSON Schema before applying something, you have to manually validate the schema again.

A workaround is to check the internal result of the schema validation. When

// the internal validateSchema.errors is null when valid schema, 
// and an array with messages when invalid
var errors = editor.validateSchema.errors; 

Makes sense to me to create a neat public API to check the validity against the configured schema.

Makes sense to me to create a neat public API to check the validity against the configured schema.

+1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fyyyyy picture fyyyyy  路  8Comments

sergibondarenko picture sergibondarenko  路  4Comments

ricardogaspar2 picture ricardogaspar2  路  3Comments

maiscourt picture maiscourt  路  5Comments

tanmayrajani picture tanmayrajani  路  4Comments