-
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
Is the Sails team willing to support beforeValidation? #6841
Comments
@cristianszwarc Thanks for posting! We'll take a look as soon as possible. In the mean time, there are a few ways you can help speed things along:
Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly. For help with questions about Sails, click here. |
@cristianszwarc Thanks for the rational and proposal to help with |
@cristianszwarc Just discussed this one with the team and we're curious of your usage case / need for |
thanks @johnabrams7 We have a base model that is used across clients, each client can configure custom fields that are then dynamically supported. When the project was moved from Mongodb to Postgres, the list of available fields got frozen in time, custom fields can't be provided anymore to clients without altering the db. Indeed there are multiple ways to deal with this scenario. But we have some constrains:
our solution:
|
@cristianszwarc Thanks for the explanation! Given your use case, it sounds like using blueprints may be more of a liability than a benefit. We recommend writing a custom action. |
While waiting for an answer we started to use a custom method in the critical places were we need to move on, if Should we close the issue and call the day? |
@cristianszwarc Awesome, glad y'all found a solution. 👍 |
@cristianszwarc I've facing a similar issue. I've been looking at intercepting the process in |
History
there is mention of a
beforeValidate
lifecycle callback but I don't see it being implemented:https://github.com/balderdashy/waterline/blob/1d5a3dc6e65fe69c061a72249019adfcf3c52cb6/lib/waterline/utils/system/lifecycle-callback-builder.js#L28
the migration to 1.0 docs states:
beforeValidate
andafterValidate
lifecycle callbacks no longer exist" https://next.sailsjs.com/documentation/upgrading/to-v-1-0Other missing lifecycle callbacks
I have been working on enabling other listed but not available lifecycle callbacks (afterFind/afterFindOne) #6839 .
Need for beforeValidate
as others, I found that if the record being created/updated contains extra a field not defined in the model, it would remove/normalise it before the
beforeCreate
orbeforeUpdate
callbacks are executed.I don't see where in the model I could add validations that are not related to individual fields, it feels that
beforeValidate
would be a great place for actions like validations across different fieldsexample. you might not want to allow a
newMember.receiveCasinoPromos
to be true whilenewMember.dob
shows is a minor.(In our edge situation we have extra dynamic fields that should affect the real fields before being discarded)
related: #5625
Question
Is the Sails team willing to support
beforeValidation
? If so, I'm happy to put some hours on it instead of creating a custom solution.cheers!
The text was updated successfully, but these errors were encountered: