mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-19 17:02:54 +00:00
14 lines
318 B
TypeScript
14 lines
318 B
TypeScript
import Ajv from 'ajv';
|
|
import schema from './schema.json';
|
|
|
|
const ajv = new Ajv({ jsonPointers: true });
|
|
const validate = ajv.compile(schema);
|
|
|
|
export default function validateSchema(json: object) {
|
|
if (validate(json) === false) {
|
|
throw new Error(JSON.stringify(validate.errors, null, 2));
|
|
}
|
|
|
|
return true;
|
|
}
|