Bug #5779

Errors in documentation for WLengthValidator

Added by Vincenzo Romano over 5 years ago. Updated over 5 years ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:
0.25 h


The documentation for WLengthValidator wrongly states that:


The strings used in this class can be translated by overriding the default values for the following localization keys:

* Wt.WLengthValidator.TooShort: The input must be at least {1} characters
* Wt.WLengthValidator.BadRange: The input must have a length between {1} and {2} characters
* Wt.WLengthValidator.TooLong: The input must be no more than {1} characters

But there are only two methods available for overriding:

void setInvalidTooShortText (const WString &text);
void setInvalidTooLongText (const WString &text);

I think that the extra mentioned item can be deleted altogether as it could make no sense in the context.


Updated by Roel Standaert over 5 years ago

That documentation is correct.

WLengthValidator uses Wt.WLengthValidator.TooShort if there's only a minimum length, Wt.WLengthValidator.TooLong if there's only a maximum length, and Wt.WLengthValidator.BadRange if both a minimum and a maximum length are set.

So there are two ways to override this text: you can use setInvalidTooShortText and setInvalidTooLongText, or you can override those values through the message resource bundle, e.g. if app is your WApplication and my_res.xml is a resources file.


Then my_res.xml could contain:

<?xml version="1.0" encoding="UTF-8" ?>
  <message id="Wt.WLengthValidator.TooShort">Override for too short message. Text should be at least {1} characters long</message>
  <message id="Wt.WLengthValidator.TooLong">Override for too long message. Text should be at most {1} characters long</message>
  <message id="Wt.WLengthValidator.BadRange">Override for bad range message. Text should be between {1} and {2} characters long</message>

I hope that clarifies it.

Also available in: Atom PDF