2929import java .math .BigInteger ;
3030import java .nio .charset .StandardCharsets ;
3131import java .nio .file .Path ;
32- import java .text .MessageFormat ;
3332import java .util .*;
3433import java .util .function .Function ;
3534import java .util .stream .Collectors ;
@@ -286,6 +285,8 @@ private JsonSchema readSchema(Path path) {
286285 .build ();
287286 SchemaValidatorsConfig config = new SchemaValidatorsConfig ();
288287 config .setPathType (PathType .JSON_POINTER );
288+ config .setLocale (specs .getLocalisationHelper ().getLocale ());
289+ config .setResourceBundle (translationBundle );
289290 return schemaFactory .getSchema (jsonNode , config );
290291 } catch (IOException e ) {
291292 throw new ValidatorException ("validator.label.exception.failedToParseJSONSchema" , e , e .getMessage ());
@@ -302,21 +303,7 @@ private List<Message> validateAgainstSchema(File schemaFile) {
302303 var schema = readSchema (schemaFile .toPath ());
303304 try {
304305 var content = objectMapper .readTree (specs .getInputFileToUse ());
305- return schema .validate (content ).stream ().map ((message ) -> {
306- String text = message .getMessage ();
307- if (this .translationBundle .containsKey (message .getType ())) {
308- var localisedTemplate = this .translationBundle .getString (message .getType ());
309- var arguments = message .getArguments ();
310- var params = new String [(arguments == null ? 0 : arguments .length ) + 1 ];
311- params [0 ] = message .getPath ();
312- if (arguments != null ) {
313- System .arraycopy (arguments , 0 , params , 1 , params .length - 1 );
314- }
315- text = MessageFormat .format (localisedTemplate , (Object []) params );
316- text = StringUtils .removeStart (text , "[] " );
317- }
318- return new Message (text , message .getPath ());
319- }).collect (Collectors .toList ());
306+ return schema .validate (content ).stream ().map ((message ) -> new Message (StringUtils .removeStart (message .getMessage (), "[] " ), message .getPath ())).collect (Collectors .toList ());
320307 } catch (IOException e ) {
321308 throw new ValidatorException ("validator.label.exception.failedToParseJSON" , e );
322309 }
0 commit comments