mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-21 13:34:04 +03:00
fix(JSON Schema Validation): handle JSON parse error
This commit is contained in:
1 parent
0c334e9560
commit
19da4e31c8
1 file changed
+8
-3
@@ -58,9 +58,14 @@ export function useJsonSchemaValidation({ json, schemaUrl, schemaData }: { json:
|
|||||||
errors.value = [];
|
errors.value = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const validator = new Validator();
|
try {
|
||||||
const validationResult = validator.validate(JSON.parse(jsonValue), schemaValue);
|
const validator = new Validator();
|
||||||
errors.value = validationResult.errors.map(error => error.stack ?? '');
|
const validationResult = validator.validate(JSON.parseBigNum(jsonValue), schemaValue);
|
||||||
|
errors.value = validationResult.errors.map(error => error.stack ?? '');
|
||||||
|
}
|
||||||
|
catch (e: any) {
|
||||||
|
errors.value = [`JSON validation error:${e.toString()}`];
|
||||||
|
}
|
||||||
}, { immediate: true });
|
}, { immediate: true });
|
||||||
|
|
||||||
return { schemas, errors };
|
return { schemas, errors };
|
||||||
|
|||||||
Reference in new issue
Block a user