lykmapipo / sails-hook-validation

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

Use Field values in i18n translations #42

Closed mortezakarimi closed 2 years ago

mortezakarimi commented 8 years ago

I think you can change your validateCustom.js to show field values on errors something like this:

var fieldValue = (typeof model.attributes[validationField][fieldError.rule] === 'undefined') ? '' : model.attributes[validationField][fieldError.rule];
var customMessage = sails.__({
                            phrase: phrase,
                            locale: locale
                        },fieldValue);

and then we can use something like this in translation files "contact.name.minLength": "minimum length is %s .",

Sorry for my bad English

armellarcier commented 7 years ago

The actual value passed to validation would be nice too.