mirror of
https://github.com/lynchmarkHQ/lynchmark.com.git
synced 2026-10-18 09:47:55 +00:00
7 lines
309 B
JavaScript
7 lines
309 B
JavaScript
const validateJSON = async (data, schema) => {
|
|
const Ajv = (await import('https://esm.sh/ajv@8.17.1')).default
|
|
const validate = new Ajv({ allErrors: true }).compile(schema)
|
|
const valid = validate(data)
|
|
return { valid, errors: validate.errors?.map(e => e.message) ?? [] }
|
|
}
|
|
export default validateJSON; |