Bug #5779
openErrors in documentation for WLengthValidator
0%
Description
The documentation for WLengthValidator wrongly states that:
i18n
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 7 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.
app->messageResourceBundle().use("my_res");
Then my_res.xml
could contain:
<?xml version="1.0" encoding="UTF-8" ?>
<messages>
<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>
</messages>
I hope that clarifies it.