mirror of
https://github.com/lynchmarkHQ/lynchmark.com.git
synced 2026-10-08 21:35:23 +00:00
8 lines
279 B
JavaScript
8 lines
279 B
JavaScript
async function validateJSON(d,s){
|
|
const {default:Ajv}=await import('https://cdn.skypack.dev/ajv');
|
|
const a=new Ajv({allErrors:true});
|
|
const v=a.compile(s);
|
|
const ok=v(d);
|
|
return{valid:ok,errors:ok?[]:(v.errors||[]).map(e=>e.message||'')};
|
|
}
|
|
export default validateJSON; |