Skip to content

Commit dcb661b

Browse files
authored
Merge pull request #1019 from ISISComputingGroup/Ticket4934_BlockServer_Macro_too_long_config_not_saved
added new macro value validator check for validating length of macro
2 parents d92120e + 37ca868 commit dcb661b

File tree

1 file changed

+9
-0
lines changed
  • base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/editing/macros

1 file changed

+9
-0
lines changed

base/uk.ac.stfc.isis.ibex.ui.configserver/src/uk/ac/stfc/isis/ibex/ui/configserver/editing/macros/MacroValueValidator.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ public class MacroValueValidator extends ModelObject implements IValidator<Strin
5959
* The message that is displayed when the regex pattern is invalid.
6060
*/
6161
public static final String PATTERN_INVALID = "Macro regex pattern invalid";
62+
/**
63+
* The message that is displayed when the value is longer than 255 character
64+
*/
65+
public static final String MAXIMUM_CHARACTER_LENGTH_LIMIT_MESSAGE = "Value cannot be longer than 255 characters";
6266

67+
private final int MAXIMUM_CHARACTER_LIMIT = 256;
68+
6369
private final Label messageDisplayer;
6470
private MacroViewModel macro;
6571
private boolean nameIsValid = true;
@@ -92,6 +98,9 @@ public IStatus validate(String text) {
9298
} else if (!matchesPattern(text)) {
9399
setShowWarningIcon(true);
94100
returnStatus = setError(PATTERN_MISMATCH_MESSAGE);
101+
} else if (text.length() >= MAXIMUM_CHARACTER_LIMIT) {
102+
setShowWarningIcon(true);
103+
returnStatus = setError(MAXIMUM_CHARACTER_LENGTH_LIMIT_MESSAGE);
95104
} else {
96105
returnStatus = setNoError();
97106
}

0 commit comments

Comments
 (0)