holyxiaoxin
holyxiaoxin

Reputation: 710

SailsJS beforeCreate and beforeUpdate duplicated method alternatives

I have a model and I check for some validations before create and update. In many instances, it applies to both beforeCreate and beforeUpdate. Is there a better way to merge these two functions, something like before_save in rails?

Upvotes: 0

Views: 269

Answers (1)

Meeker
Meeker

Reputation: 5979

Yes, you can define beforeValidate or afterValidate which will run on both save and create.

Upvotes: 2

Related Questions