mirror of
https://github.com/lynchmarkHQ/lynchmark.com.git
synced 2026-10-15 16:47:52 +00:00
8 lines
290 B
JavaScript
8 lines
290 B
JavaScript
async function validateJSON(o, s) {
|
|
const { default: Ajv } = await import('https://esm.sh/ajv@8');
|
|
const a = new Ajv({ allErrors: true });
|
|
const v = a.compile(s);
|
|
const ok = v(o);
|
|
return { valid: ok, errors: ok ? [] : v.errors.map(e => e.message) };
|
|
}
|
|
export default validateJSON; |