mirror of
https://github.com/lynchmarkHQ/lynchmark.com.git
synced 2026-10-11 23:05:21 +00:00
13 lines
427 B
JavaScript
13 lines
427 B
JavaScript
const validateJSON = async (json, schema) => {
|
|
const { default: Ajv } = await import('https://cdn.skypack.dev/ajv@8.12.0');
|
|
const ajv = new Ajv({ allErrors: true });
|
|
const validate = ajv.compile(schema);
|
|
const valid = validate(json);
|
|
return {
|
|
valid,
|
|
errors: valid ? [] : validate.errors.map(e => `${e.instancePath} ${e.message}`)
|
|
};
|
|
};
|
|
export default validateJSON;
|
|
// Generation time: 4.839s
|
|
// Result: PASS
|