I am trying to use the JavaScript port and try to replace the ajv implementation.
The current difficultly is hard to form error message even with the tracing callback.
const instance = { name: "John", age: 30 };
const result = evaluator.validate(instance, (type, valid, instruction, evaluatePath, instanceLocation, annotation) => {
// type - the pre / post information is useless for error message
// instruction - information for the validator, hard to use
// valid - information to know which instanceLocation is invalid
// evaluatePath - schema pointer
// instanceLocation - property pointer
// annotation - not discovered how to use
});
console.log(result); // true or false
From the evaluation callback, the only useful information are
valid - Used to identify which schema location is not valid.
evaluatePath - Used to form the error message where is not valid.
instanceLocation - Used to form the error message where is not valid.
It is still missing the information of why it is not valid on the location.
For example, a simple type validation.
We can only use the information on evaluatePath to tell the type is not match.
But we can never tell which type it should be.
I am trying to use the JavaScript port and try to replace the
ajvimplementation.The current difficultly is hard to form error message even with the tracing callback.
From the evaluation callback, the only useful information are
valid- Used to identify which schema location is not valid.evaluatePath- Used to form the error message where is not valid.instanceLocation- Used to form the error message where is not valid.It is still missing the information of why it is not valid on the location.
For example, a simple type validation.
{ "type": "boolean" }We can only use the information on
evaluatePathto tell the type is not match.But we can never tell which type it should be.