mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-14 00:27:55 +00:00
Docs: Update benchmark for minimax/minimax-m2.1
This commit is contained in:
23
tests/8_json_validator/outputs/minimax_minimax-m2.1.js
Normal file
23
tests/8_json_validator/outputs/minimax_minimax-m2.1.js
Normal file
@@ -0,0 +1,23 @@
|
||||
async function validateJSON(data, schema) {
|
||||
const Ajv = (await import('https://cdn.jsdelivr.net/npm/ajv@8.12.0/dist/ajv2019.min.js')).default;
|
||||
|
||||
const ajv = new Ajv({ allErrors: true, strict: false });
|
||||
const validate = ajv.compile(schema);
|
||||
const valid = validate(data);
|
||||
|
||||
if (valid) {
|
||||
return { valid: true, errors: [] };
|
||||
}
|
||||
|
||||
const errors = validate.errors.map(error => {
|
||||
const message = `${error.instancePath} ${error.message}`;
|
||||
return error.params && error.params.allowedValues
|
||||
? `${message} (allowed: ${error.params.allowedValues.join(', ')})`
|
||||
: message;
|
||||
});
|
||||
|
||||
return { valid: false, errors };
|
||||
}
|
||||
export default validateJSON;
|
||||
// Generation time: 6.888s
|
||||
// Result: FAIL
|
||||
Reference in New Issue
Block a user