mirror of
https://github.com/lynchmarkHQ/lynchmark.com.git
synced 2026-10-08 21:35:23 +00:00
12 lines
375 B
JavaScript
12 lines
375 B
JavaScript
const validateJSON = async (json, schema) => {
|
|
const { default: Ajv } = await import('https://esm.sh/ajv');
|
|
const validate = new Ajv().compile(schema);
|
|
const valid = validate(json);
|
|
return {
|
|
valid,
|
|
errors: valid ? [] : validate.errors.map(e => `${e.instancePath} ${e.message}`)
|
|
};
|
|
};
|
|
export default validateJSON;
|
|
// Generation time: 103.740s
|
|
// Result: PASS
|