@@ -14,9 +14,11 @@ import { Localization } from "./localization.js";
1414
1515/** @type API.jsonSchemaErrors */
1616export const jsonSchemaErrors = async ( errorOutput , schemaUri , instance , options = { } ) => {
17- const normalizedErrors = await normalizedOutput ( instance , errorOutput , schemaUri ) ;
1817 const rootInstance = Instance . fromJs ( instance ) ;
19- const localization = await Localization . forLocale ( options . locale ?? "en-US" ) ;
18+ const [ normalizedErrors , localization ] = await Promise . all ( [
19+ normalizedOutput ( rootInstance , errorOutput , schemaUri ) ,
20+ Localization . forLocale ( options . locale ?? "en-US" )
21+ ] ) ;
2022 return await getErrors ( normalizedErrors , rootInstance , localization ) ;
2123} ;
2224
@@ -28,12 +30,11 @@ export const setNormalizationHandler = (schemaUri, handler) => {
2830 normalizationHandlers [ schemaUri ] = handler ;
2931} ;
3032
31- /** @type (instance: API.Json , errorOutput: API.OutputUnit, subjectUri: string) => Promise<API.NormalizedOutput> */
32- async function normalizedOutput ( instance , errorOutput , subjectUri ) {
33+ /** @type (value: JsonNode , errorOutput: API.OutputUnit, subjectUri: string) => Promise<API.NormalizedOutput> */
34+ async function normalizedOutput ( value , errorOutput , subjectUri ) {
3335 const schema = await getSchema ( subjectUri ) ;
3436 const errorIndex = await constructErrorIndex ( errorOutput , schema ) ;
3537 const { schemaUri, ast } = await compile ( schema ) ;
36- const value = Instance . fromJs ( instance ) ;
3738 return evaluateSchema ( schemaUri , value , { ast, errorIndex, plugins : [ ...ast . plugins ] } ) ;
3839}
3940
0 commit comments