You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's prototype API for setting error messages through i18n and overloads. Below are some examples of how it's supposed to look like.
Example 1 (setting error message through i18n objects):
datePicker.setMin(minDate);
datePicker.getI18n().setBadInputErrorMessage("Date has incorrect format");
datePicker.getI18n().getBadInputErrorMessage();
datePicker.getI18n().setMinErrorMessage("Date must be later than " + minDate);
datePicker.getI18n().getMinErrorMessage();
Example 2 (setting error messages through constraint method overloads) see #6280 (comment)
// These are just aliases for the corresponding i18n methods.datePicker.setMin(minDate, "Date must be earlier than " + minDate);
datePicker.setMax(maxDate, "Date must be later than " + maxDate);
Example 3 (cross-field validation with Binder):
datePicker.setMin(minDate);
datePicker.getI18n().setBadInputErrorMessage("Date has incorrect format");
datePicker.getI18n().setMinErrorMessage("Date must be later than " + minDate);
binder.forField(datePicker)
// Disable the default validator
.withDefaultValidator(false)
// Add a custom validator
.withValidator(dateOrAnotherFieldPredicate, "You must fill either one field or another")
// Add the default validator manually. It will use error messages from the i18n object
.withValidator(datePicker.getDefaultValidator())
vursen
changed the title
Prototype API for setting error messages through i18n and overloads
Prototype API for setting error messages through i18n and overloads [3 days]
May 8, 2024
I personally would love to have the option to have setMin(LocalDate min, ErrorMessageProvider errorMessageProvider) instead of the i18n object for full flexibility.
After some prototyping, we decided to postpone introducing constraint method overloads. Implementing them now through i18n would require a breaking change later to support ErrorMessageProvider. We plan to revisit this when the Flow components fully integrate with the new i18n mechanism to explore other alternatives.
Let's prototype API for setting error messages through i18n and overloads. Below are some examples of how it's supposed to look like.
Example 1 (setting error message through i18n objects):
Example 2 (setting error messages through constraint method overloads)see #6280 (comment)Example 3 (cross-field validation with Binder):
Additional context
The text was updated successfully, but these errors were encountered: