dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 379 forks source link

validations after beforeCreate #567

Open lagonnebula opened 9 years ago

lagonnebula commented 9 years ago

I have a model for User with a password.

So i added a validations method like :

password : orm.enforce.security.password("lu4", "So easy password"),

to check if the pass have minimum security ( simple example ).

And i added a beforeCreate hook to put the password encrypted in the database:

beforeCreate: function(next){
    var shasum = crypto.createHash("sha1");
    shasum.update(this.password);
    this.password = shasum.digest("hex");
    return next();
}

But here i have an erro telling me that my password is too easy because i don'tt have any upercase.

How can i procede ?

jacobp100 commented 9 years ago

afterValidate, surely? I think you'll have issues with updating the password, unless we get https://github.com/dresende/node-orm2/issues/570