mirror of
https://github.com/lynchmarkHQ/lynchmark.com.git
synced 2026-10-12 23:35:31 +00:00
9 lines
350 B
JavaScript
9 lines
350 B
JavaScript
async function validateJSON(data, schema) {
|
|
const { default: Ajv } = await import('https://esm.sh/ajv@8');
|
|
const v = new Ajv({ allErrors: true }).compile(schema);
|
|
const isValid = v(data);
|
|
return { valid: isValid, errors: isValid ? [] : v.errors.map(e => e.message) };
|
|
}
|
|
export default validateJSON;
|
|
// Generation time: 44.300s
|
|
// Result: PASS
|