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