-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access to instance inside LifeCycle Callback #5764
Comments
I have gotten around this by doing this admin:{
type:"boolean",
defaultsTo:false,
boolean:function(){
log.info("using ugly method to valid");
if(!this._admin){
log.info("the user doesn't have permission to change admin status");
this.admin=false;
}else{
log.info("the user has permission to change the status");
}
return true;
}
}, this was done on the admin attribute because i have access to the instances here. but it's a improper use of the attributes validation because i am not checking if it is boolean and i am always returning true. I just don't understand why i can have access to the instance here but not inside the beforeValidate function |
So the |
Thanks for posting, @shavyg2. I'm a repo bot-- nice to meet you! It has been 30 days since there have been any updates or new comments on this page. If this issue has been resolved, feel free to disregard the rest of this message. On the other hand, if you are still waiting on a patch, please:
Thanks so much for your help! |
Reopening until this goes into the backlog. |
Added to the roadmap |
I have an issue that i thought would be pretty simple to get around but i am having some trouble. I don't know if this is the fault of the waterline or i am misunderstanding something.
I have a use case like this
is there a way to have access to the instance of the model? this is because there are values that are on the model that are not persisted but are needed for the validation of the model.
This approach may not be the greatest and it can be done in a controller yes. But this is just to validate my model.
I can do validation in the controller and then validation on the model, but it seems unneeded to do this. I would much rather do the validation all in one place. Waterline Validation of the model is already pretty good and allows so much flexibility why would i off shoot one extra validation outside. Doesn't make much sense.
The text was updated successfully, but these errors were encountered: