lykmapipo / sails-hook-validation

Custom validation error messages for sails model with i18n support
104 stars 29 forks source link

Option to disable i18n translation #58

Open snnrk opened 6 years ago

snnrk commented 6 years ago

Hi,

My app needs to include the threshold into the message on validation error. (eg. "Name should be within 15 characters.") In the case of the message above, the code can be written like this:

req.__('Name should be within %s characters.', User.attributes.name.maxLength);

But sails-hook-validation translate the message inside when the current or default locale is set. This behavior disturbs to replace the specifier in the message with the value. The reason is:

So I added the option to disable i18n translation in the hook. Using this option, I can receive the raw customMessage (formated as "model.field.rule').

Please pull them if acceptable.