mirror of
https://github.com/lynchmarkHQ/lynchmark.com.git
synced 2026-10-17 17:27:53 +00:00
Docs: Update benchmark results
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
export async function validateJSON(data, schema) {
|
||||
const { default: Ajv } = await import('https://esm.sh/ajv@8?bundle');
|
||||
const ajv = new Ajv({ allErrors: true, strict: false });
|
||||
const validate = ajv.compile(schema);
|
||||
const valid = validate(data);
|
||||
const errors = valid ? [] : (validate.errors || []).map(e => `${e.instancePath || '/'} ${e.message || ''}`.trim());
|
||||
return { valid, errors };
|
||||
const fetchAjv=(()=>{let p;return()=>p??=import('https://cdn.jsdelivr.net/npm/ajv@8/dist/ajv.min.js?module').then(({default:A})=>new A({allErrors:true,strict:false}));})();
|
||||
|
||||
async function validateJSON(data,schema){
|
||||
const ajv=await fetchAjv();
|
||||
const validate=ajv.compile(schema);
|
||||
const valid=validate(data);
|
||||
return {valid,errors:valid?[]:validate.errors.map(e=>e.message||'Invalid')};
|
||||
}
|
||||
export default validateJSON;
|
||||
Reference in New Issue
Block a user