How can we improve Breeze.js?

Localization of validation error messages

We are using BreezeJS in a fincancial bookkeeping DurandalJS/KnockoutJS based SPA.

We have made a really nice reusable ui component for editing properties of breeze entities in the web ui, encapsulating label element + form field (with localized date/number formatting) + validation callout behavior showing the validation error messages.

This editor component works really well; fueled by the breeze metadata providing extensive type information about properties we can dynamically display an appropriate form field, and the breeze validation framework helps setting maxLength to the form fields + required validation for non-nullable fields.
We are also of course utilizing the extensible validation model in BreezeJS with our custom validatiors where needed.

The only minor problem we have now is related to localizing the validation error messages.

In our application, you may change user language at all times.
When changing language in the client, the client basically downloads the RESX file serialized as JSON from the server (in the language/culture requested by the user).

The RESX contains translations for all the standard breeze.Validator.messageTemplates, and after fetching the translated RESX, the client sets the messageTemplates to the localized values.

The problem is that for the validators that were already created in the client before the user changed language, the re-localization of the messageTemplates are not applied.

If the breeze validators would get the error message to show from breeze.Validator.messageTemplates at VALIDATION time (each time validation occurs), instead of once on validator INITIALIZATION time, this would not have been a problem for us.

This is probably very easy to fix to implement in breeze, and it would mean a lot to our application.

I think this solution would also be more flexible for most breeze based application development.

Hoping to be prioritized!

48 votes
Sign in
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
Jørn Andre Sundt shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →


Sign in
Sign in with: facebook google
Signed in as (Sign out)
  • sercan commented  ·   ·  Flag as inappropriate

    Redefining the validator before the fetchmetaData,and injecting the localized message template in validation function would be the trick.

    breeze.Validator.required = function (context) {
    var valFn = function (value, ctx) {
    ctx.messageTemplate = 'Your localizaed message template'
    return value && value !== 0;
    return new breeze.Validator("required", valFn, context);
    breeze.Validator.registerFactory(breeze.Validator.required, "required");

Feedback and Knowledge Base