mirror of
https://github.com/deunix-educ/PyQuest.git
synced 2026-11-25 08:19:44 +01:00
Add LevelLinter (static checks) and LevelChecker (execution checks) shared by tests and the future author editor
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { dereference } from './dereference.js';
|
||||
import { validate } from './validate.js';
|
||||
export class Validator {
|
||||
schema;
|
||||
draft;
|
||||
shortCircuit;
|
||||
lookup;
|
||||
constructor(schema, draft = '2019-09', shortCircuit = true) {
|
||||
this.schema = schema;
|
||||
this.draft = draft;
|
||||
this.shortCircuit = shortCircuit;
|
||||
this.lookup = dereference(schema);
|
||||
}
|
||||
validate(instance) {
|
||||
return validate(instance, this.schema, this.draft, this.lookup, this.shortCircuit);
|
||||
}
|
||||
addSchema(schema, id) {
|
||||
if (id) {
|
||||
schema = { ...schema, $id: id };
|
||||
}
|
||||
dereference(schema, this.lookup);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user