Open josejachuf opened 3 years ago
Or if it is not a bug, how can I do this dynamically?
@josejachuf I'm sorry, but I'm not sure I got the issue.
What do you mean by
lambda runs only once and after that first time does not come to run, then it is always calling db.where from the first condition
Can you explain it differently?
Hi @gi0baro
I hoped that by changing the value of session.f2 Validation is dynamic and contextual to what contains the value of session.f2.
About lambda, I thought that every time the validation was executed, I was going to take the conditions of the value of session.f2
Jose
@josejachuf so, theoretically speaking, the validation functions get called every time you pass a value for the relevant field. Also theoretically speaking, the session values should be the ones part of the dedicated request. Then, if something doesn't work in this way, there's a bug and I will investigate.
Nevertheless, under an architecting point of view, I strongly disagree with the principle of binding models with requests, for a couple of reasons:
So IMHO the validation logics performed against users, or in general the request flow should be made in the C part of MVC paradigm, which means routes or pipes in Emmett.
thanks @gi0baro for the info.
I ended up resolving as you say in the controller.
Jose
I have this validation
'f1': {'in': {'dbset': lambda db: db.where(db.A.f2 == session.f2)}}
In another way:
The problem I have is that lambda runs only once and after that first time does not come to run, then it is always calling db.where from the first condition. I can check it with the print() that only runs once
Jose