mirror of
https://github.com/lynchmarkHQ/lynchmark.com.git
synced 2026-10-17 01:07:53 +00:00
7 lines
287 B
JavaScript
7 lines
287 B
JavaScript
let a
|
|
const validateJSON = async (d, s) => {
|
|
a ??= new (await import('https://esm.sh/ajv@8')).default({ allErrors: !0 })
|
|
const v = a.compile(s), r = v(d)
|
|
return { valid: r, errors: r ? [] : v.errors.map(e => `${e.instancePath} ${e.message}`.trim()) }
|
|
}
|
|
export default validateJSON; |