i18n on validation and database errors
See original GitHub issueHello! 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:
- Created 8 years ago
- Reactions:13
- Comments:8 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Still an issue, it would be fantastic to have a way of supporting translatable validation messages.
Since string matching doesn’t work in this case because the value is dynamic I’m +1 for providing a
typeorcodeassociated with the validation error.