Skip to content

Commit

Permalink
[#12]
Browse files Browse the repository at this point in the history
rework validation
fix constructor to not add a message if null
use empty constructor if all is well
  • Loading branch information
jj committed Feb 28, 2019
1 parent 4ddf3a9 commit 096d812
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ public ValidationResult validateIfNecessary(T metadataResolver) {
this.validators
.stream()
.filter(v -> v.supports(metadataResolver))
.forEach(v -> {
validationResult.getErrorMessages().addAll(v.validate(metadataResolver).getErrorMessages());
});
.forEach(v -> v.validate(metadataResolver).getErrorMessages().stream().filter(m -> m != null).forEach(r -> validationResult.getErrorMessages().add(r)));
return validationResult;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class ValidationResult {
public ValidationResult() {}

public ValidationResult(String errorMessage) {
this.errorMessages.add(errorMessage);
if (errorMessage != null) {
this.errorMessages.add(errorMessage);
}
}

private List<String> errorMessages = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public ValidationResult validate(ResourceBackedMetadataResolver resolver) {
catch (ResourceBackedMetadataResolver.InvalidResourceTypeException e) {
return new ValidationResult(e.getMessage());
}
return new ValidationResult(null);
return new ValidationResult();
}
}

0 comments on commit 096d812

Please sign in to comment.