lykmapipo / sails-hook-validation

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

Errors on Sails 1.0 installations #50

Closed macfeaster closed 7 years ago

macfeaster commented 7 years ago

Thanks for a great plugin!

With Sails 1.0, the plugin fails. These are the errors I have encountered so far:

The first should be easily fixed by changing from the Sails built-in lodash to your own instance. Not sure about the second one though.

hebertbanes commented 7 years ago

you can fixed it changing the following at index.js: module.exports = function(sails) { //patch sails model //to add custom errors message //logic function patch() { sails .util ._ .forEach(sails.models, function(model) { //bind path validate //on concrete models //and left derived model //build from associations if (model.globalId) {

TO

module.exports = function(sails) { //patch sails model //to add custom errors message //logic function patch() { //Hebert Update: sails.util._ doesnt exist anymore at v1.x Object.keys(sails.models).forEach(function (model){ //bind path validate //on concrete models //and left derived model //build from associations if (model.globalId) {

Replace sails.util._forEach with Object.keys(sails.models).forEach