Closed slavafomin closed 8 years ago
hi @slavafomin
Custom validation messages are available in error.Errors
. Try to use that and see if its working.
Hope it helps.
It doesn't work for me too. I have changed error.ValidationError to error.invalidAttributes and that helped. I can't understand this behavior because there is a getter for ValidationError https://github.com/balderdashy/waterline/blob/master/lib/waterline/error/WLValidationError.js#L132
@Shkryob & @slavafomin
sails-hook-validation
works by adding custom errors message in error.Errors
. It also requires you to define i18n files or custom validation messages.
Try to check Sample model and i18n files.
Hope it helps.
@lykmapipo ok probably I was not clear. I have changed ValidationError to invalidAttributes in plugin's code, not in my code. Please see https://github.com/lykmapipo/sails-hook-validation/pull/22 I believe this changes are relevant because ValidationError is deprecated in Sails anyway (https://github.com/balderdashy/waterline/blob/master/lib/waterline/error/WLValidationError.js#L132)
@Shkryob
Which sails version you using?
@lykmapipo I am using Sails 0.11.0
Not working for me either.
TypeError: undefined is not a function at grabLocale (...node_modules/sails-hook-validation/index.js:73:63) at routeTargetFnWrapper (...node_modules/sails/lib/router/bind.js:179:5) at callbacks (...node_modules/sails/node_modules/express/lib/router/index.js:164:37)
Does the hook require to set validationMessages for all the models?
@Clan-Utility
Based on its purpose. Its YES
@Shkryob
:+1:
@Clan-Utility @slavafomin checkout v0.4.3
Hello!
I'm trying to use this hook in order to translate my application, however, it's not working.
As you can see I'm also using
sails-auth
in order to implement authentication.config/locales/ru.json:
I'm getting the standard error message instead of localized one.
Please advise, thanks!