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