Project

General

Profile

Actions

Bug #5779

open

Errors in documentation for WLengthValidator

Added by Vincenzo Romano almost 7 years ago. Updated almost 7 years ago.

Status:
New
Priority:
Low
Assignee:
-
Target version:
Start date:
06/24/2017
Due date:
% Done:

0%

Estimated time:
0:15 h

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.

Actions #1

Updated by Roel Standaert almost 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.

Actions

Also available in: Atom PDF