mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-06-28 04:12:13 +00:00
Docs: Update benchmark for anthropic/claude-fable-5
This commit is contained in:
30
tests/8_json_validator/outputs/anthropic_claude-fable-5.js
Normal file
30
tests/8_json_validator/outputs/anthropic_claude-fable-5.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const validateJSON = (() => {
|
||||
let ajv;
|
||||
|
||||
const load = async () => {
|
||||
if (ajv) return ajv;
|
||||
const [{ default: Ajv }, { default: addFormats }] = await Promise.all([
|
||||
import('https://cdn.jsdelivr.net/npm/ajv@8/+esm'),
|
||||
import('https://cdn.jsdelivr.net/npm/ajv-formats@3/+esm')
|
||||
]);
|
||||
ajv = new Ajv({ allErrors: true, strict: false });
|
||||
addFormats(ajv);
|
||||
return ajv;
|
||||
};
|
||||
|
||||
const format = e =>
|
||||
`${e.instancePath || '/'} ${e.message}${e.params?.allowedValues ? `: ${e.params.allowedValues.join(', ')}` : ''}`;
|
||||
|
||||
return async (data, schema) => {
|
||||
try {
|
||||
const validator = (await load()).compile(schema);
|
||||
const valid = validator(data);
|
||||
return { valid, errors: valid ? [] : validator.errors.map(format) };
|
||||
} catch (err) {
|
||||
return { valid: false, errors: [`Schema error: ${err.message}`] };
|
||||
}
|
||||
};
|
||||
})();
|
||||
export default validateJSON;
|
||||
// Generation time: 13.342s
|
||||
// Result: PASS
|
||||
Reference in New Issue
Block a user