mirror of
https://github.com/lynchmarkHQ/lynchmark.com.git
synced 2026-10-17 01:07:53 +00:00
Docs: Update benchmark results
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
let ajvPromise;
|
||||
|
||||
const validateJSON = async (data, schema) => {
|
||||
const { default: Ajv } = await (ajvPromise ||= import('https://cdn.jsdelivr.net/npm/ajv@8.12.0/+esm'));
|
||||
|
||||
const ajv = new Ajv({ allErrors: true });
|
||||
const validate = ajv.compile(schema);
|
||||
const valid = validate(data);
|
||||
|
||||
const errors = valid ? [] : validate.errors.map(
|
||||
e => (`${e.instancePath || 'root'} ${e.message}`).trim()
|
||||
);
|
||||
|
||||
return { valid, errors };
|
||||
};
|
||||
export default validateJSON;
|
||||
Reference in New Issue
Block a user