I have a use case like below:

TextField senrcv = new TextField("Sender/Receiver"); senrcv.setMaxLength(11); senrcv.addValidator(new StringLengthValidator("send Error", 4, 11, true)); senrcv.setRequired(false); The problem is, when this field is empty, StringLengthValidator returns false and I see error. But, I’m saying that null value is OK, and field is not required.

First couple of lines fomr isValidValue method of StringLengthValidator

@Override protected boolean isValidValue(String value) { if (value == null) { return allowNull; } But issue, value is empty string, not null, so it continue to the validation methods.

AM I missing something?

Would senrcv.setNullRepresentation(“”) help?

No, That doesnt work either.

Ah, you also need setNullSettingAllowed(true).