mirror of
https://github.com/lynchmarkHQ/lynchmark.com.git
synced 2026-10-15 16:47:52 +00:00
10 lines
312 B
JavaScript
10 lines
312 B
JavaScript
const validateJSON = async (d, s) => {
|
|
const { default: A } = await import('https://esm.sh/ajv@8.17.1')
|
|
const v = new A({ allErrors: true }).compile(s)
|
|
const r = v(d)
|
|
return {
|
|
valid: r,
|
|
errors: r ? [] : v.errors.map(e => `${e.instancePath} ${e.message}`.trim())
|
|
}
|
|
}
|
|
export default validateJSON; |