use of org.leadpony.justify.api.Problem in project devspaces-images by redhat-developer.
the class ErrorMessageComposer method extractMessages.
/**
* Parses {@link Problem} list into an error string. Each problem is recursively parsed to extract
* nested errors if any.
*
* @param validationErrors Schema validation problems list
* @return composite error string
*/
public String extractMessages(List<Problem> validationErrors, StringBuilder messageBuilder) {
for (Problem problem : validationErrors) {
int branchCount = problem.countBranches();
if (branchCount == 0) {
messageBuilder.append(getMessage(problem));
} else {
messageBuilder.append(problem.getMessage()).append(": [");
for (int i = 0; i < branchCount; i++) {
extractMessages(problem.getBranch(i), messageBuilder);
}
messageBuilder.append("]");
}
}
return messageBuilder.toString();
}
Aggregations