Skip to content

Commit

Permalink
Merge pull request #1074 from scottgonzalez/age-group-code-validator
Browse files Browse the repository at this point in the history
Age Group: Proper validation for code length
  • Loading branch information
jflamy authored Aug 22, 2024
2 parents a3a5efd + 43a1a8b commit 48abaf9
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ public Component buildNewForm(CrudOperation operation, AgeGroup aFromDb, boolean
formLayout.addFormItem(codeField, Translator.translate("AgeGroupCode"));
int maxLength = 5;
codeField.setRequired(true);
codeField.setMaxLength(maxLength);
this.binder.forField(codeField)
.withValidator(
new StringLengthValidator(Translator.translate("ThisFieldIsRequired", maxLength), 1, maxLength))
new StringLengthValidator(Translator.translate("ThisFieldIsRequired", maxLength), 1, null))
.withValidator(
new StringLengthValidator(Translator.translate("CodeMustBeShort", maxLength), 0, maxLength))
.bind(AgeGroup::getCode, AgeGroup::setCode);
Expand Down

0 comments on commit 48abaf9

Please sign in to comment.