3

I saw that the beforeValidation is called for both create and update so I'm thinking of using this callback to manipulate the posted data before saving to the database but it seems like beforeValidation is not being called because _csrf is being save in the database and the name is not slugified.

Example:

var slugify = require('slug');
.....
beforeValidation: function(values, next){
 // don't save _csrf token in database
 if(values._csrf) delete values._csrf;
 // slugify the name before saving in the database
 values.name = slugify(values.name);
 next();
} 

Thanks

ginad
  • 1,863
  • 2
  • 27
  • 42

1 Answers1

7

Because waterline lifecycle callback names have changed :)

beforeValidation is now beforeValidate, and afterValidation is now afterValidate.

sgress454
  • 24,870
  • 4
  • 74
  • 92
zieglar
  • 830
  • 8
  • 10