mirror of
https://github.com/lynchmarkHQ/lynchmark.com.git
synced 2026-10-19 02:07:52 +00:00
Docs: Update benchmark results
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
const validateJSON=async(j,s)=>{
|
||||
const{default:Ajv}=await import('https://esm.sh/ajv@8')
|
||||
const{default:f}=await import('https://esm.sh/ajv-formats@2')
|
||||
const a=new Ajv({allErrors:1,strict:false})
|
||||
f(a)
|
||||
const v=a.compile(s)
|
||||
const ok=v(j)
|
||||
return{valid:ok,errors:ok?[]:(v.errors||[]).map(e=>`${e.instancePath||'/'} ${e.message}`.trim())}
|
||||
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 };
|
||||
}
|
||||
export default validateJSON;
|
||||
Reference in New Issue
Block a user