Skip to content

Commit fbb417a

Browse files
committed
Update to json-schema-validator 1.0.82.
1 parent a959cd2 commit fbb417a

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

jsonvalidator-common/src/main/java/eu/europa/ec/itb/json/validation/JSONValidator.java

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.math.BigInteger;
3030
import java.nio.charset.StandardCharsets;
3131
import java.nio.file.Path;
32-
import java.text.MessageFormat;
3332
import java.util.*;
3433
import java.util.function.Function;
3534
import 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

Comments
 (0)