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

OO-4388: validate length of text fields in metadata form

parent 6163a55a
No related branches found
No related tags found
No related merge requests found
......@@ -549,9 +549,32 @@ public class MetaInfoFormController extends FormBasicController {
}
}
valid &= validateTextfield(language, 16);
valid &= validateTextfield(title, 2000);
valid &= validateTextfield(comment, 32000);
valid &= validateTextfield(publisher, 2000);
valid &= validateTextfield(creator, 2000);
valid &= validateTextfield(city, 255);
valid &= validateTextfield(sourceEl, 2000);
valid &= validateTextfield(pages, 2000);
valid &= validateTextfield(filename, 255);
valid &= validateTextfield(url, 4000);
return valid;
}
private boolean validateTextfield(TextElement textEl, int maxSize) {
boolean allOk = true;
textEl.clearError();
if(textEl.getValue() != null && textEl.getValue().length() >= maxSize) {
textEl.setErrorKey("form.error.toolong", new String[] { Integer.toString(maxSize) });
allOk &= false;
}
return allOk;
}
/**
* Get the form item representing this form
*
......
......@@ -237,11 +237,11 @@ public class EditTaxonomyLevelController extends FormBasicController {
boolean allOk = true;
textEl.clearError();
if(!StringHelper.containsNonWhitespace(identifierEl.getValue())) {
identifierEl.setErrorKey("form.legende.mandatory", null);
if(!StringHelper.containsNonWhitespace(textEl.getValue())) {
textEl.setErrorKey("form.legende.mandatory", null);
allOk &= false;
} else if(identifierEl.getValue().length() >= maxSize) {
identifierEl.setErrorKey("form.error.toolong", new String[] { Integer.toString(maxSize) });
} else if(textEl.getValue().length() >= maxSize) {
textEl.setErrorKey("form.error.toolong", new String[] { Integer.toString(maxSize) });
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