Skip to content
Snippets Groups Projects
Commit ff79a249 authored by srosse's avatar srosse
Browse files

OO-5005: validate length of curriculum identifier and name

parent 029bf675
No related branches found
No related tags found
No related merge requests found
...@@ -172,15 +172,22 @@ public class EditCurriculumController extends FormBasicController { ...@@ -172,15 +172,22 @@ public class EditCurriculumController extends FormBasicController {
protected boolean validateFormLogic(UserRequest ureq) { protected boolean validateFormLogic(UserRequest ureq) {
boolean allOk = super.validateFormLogic(ureq); boolean allOk = super.validateFormLogic(ureq);
displayNameEl.clearError(); allOk &= validateTextElement(displayNameEl, 64, true);
if(!StringHelper.containsNonWhitespace(displayNameEl.getValue())) { allOk &= validateTextElement(identifierEl, 64, true);
displayNameEl.setErrorKey("form.legende.mandatory", null);
allOk &= false;
}
identifierEl.clearError(); return allOk;
if(!StringHelper.containsNonWhitespace(identifierEl.getValue())) { }
identifierEl.setErrorKey("form.legende.mandatory", null);
private boolean validateTextElement(TextElement el, int maxLength, boolean mandatory) {
boolean allOk = true;
el.clearError();
String val = el.getValue();
if(!StringHelper.containsNonWhitespace(val) && mandatory) {
el.setErrorKey("form.legende.mandatory", null);
allOk &= false;
} else if(StringHelper.containsNonWhitespace(val) && val.length() > maxLength) {
el.setErrorKey("input.toolong", new String[]{ Integer.toString(maxLength) });
allOk &= false; allOk &= false;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment