added messageArgument aware method

This commit is contained in:
patrick-werner 2020-02-25 19:00:52 +01:00
parent 4cd4044a0e
commit 2a2d9575e5
1 changed files with 11 additions and 1 deletions

View File

@ -149,7 +149,7 @@ public class BaseValidator {
} }
return thePass; return thePass;
} }
/** /**
* Test a rule and add a {@link IssueSeverity#INFORMATION} validation message if the validation fails. And mark it as a slicing hint for later recovery if appropriate * Test a rule and add a {@link IssueSeverity#INFORMATION} validation message if the validation fails. And mark it as a slicing hint for later recovery if appropriate
* *
@ -279,6 +279,8 @@ public class BaseValidator {
* Set this parameter to <code>false</code> if the validation does not pass * Set this parameter to <code>false</code> if the validation does not pass
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation) * @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
*/ */
//todo: delete this when finished i18n
protected boolean rule(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg) { protected boolean rule(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg) {
if (!thePass) { if (!thePass) {
addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.ERROR); addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.ERROR);
@ -286,6 +288,14 @@ public class BaseValidator {
return thePass; return thePass;
} }
protected boolean rule(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String theMessage, Object... theMessageArguments) {
if (!thePass) {
String message = formatMessage(theMessage, theMessageArguments);
addValidationMessage(errors, type, -1, -1, path, message, IssueSeverity.ERROR);
}
return thePass;
}
public boolean rule(List<ValidationMessage> errors, Source source, IssueType type, String path, boolean thePass, String msg) { public boolean rule(List<ValidationMessage> errors, Source source, IssueType type, String path, boolean thePass, String msg) {
if (!thePass) { if (!thePass) {
addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.ERROR, source); addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.ERROR, source);