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