question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

i18n on validation and database errors

See original GitHub issue

Hello! When I create a model and I define a validation over an attribute, I can define my own messages:

sequelize.define('Foo', {
  foo: {
    type: Sequelize.STRING,
    validate: {
      isInt: {
         msg: "Must be an integer number of pennies"
       }
    }
  }
}

In this case, you can translate the message as you want. On the other hand, when an sql validation error is thrown, the messages is only in English lib/data-types.js

INTEGER.prototype.validate = function(value) {
  if (!Validator.isInt(value)) {
    throw new sequelizeErrors.ValidationError(util.format('%j is not a valid integer', value));
  }
  return true;
};

How can I translate this messages? Why It doesn’t have an i18n file to translate it?

Thank you!

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:13
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
misterdaicommented, Jun 29, 2017

Still an issue, it would be fantastic to have a way of supporting translatable validation messages.

2reactions
fixecommented, Aug 25, 2015

Since string matching doesn’t work in this case because the value is dynamic I’m +1 for providing a type or code associated with the validation error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I18n Validation Errors
I18n Validation Errors. Usually I18n involves defining some varaible of text and rendering that instead of the actual text so that you can...
Read more >
The Basics of Rails I18n - Translate errors, models, and ...
ActiveRecord has some built-in validation errors that are raised if your record is invalid. Consider this example:.
Read more >
Rails 3 customize validate's error with i18n
Now It works fine !!! So why is it which I have to add activerecord before uniqueness validation but other ( presence, length,...
Read more >
Object Manager Loader errors encountered when loading ...
Object Manager Loader errors encountered when loading I18N international strings after upgrade to OpenPages 7.4 - DB2 databases only ...
Read more >
Exception Handling and I18N on Spring Boots APIs
I18N is a short name invented for the term internationalization. ... Since multiple validation errors might occur, we map the error codes to ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found