-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Cloud functions and Typescript No argument for validationHandler in beforeSave trigger #7016
Comments
Thanks for reporting. To report an issue, please use the issue template provided when you create an issue. The template asks for essential information which helps us to investigate the issue. |
Sorry, updated ! |
I can confidently say I have no idea how typescript works, but it seems as the issue is here, in the typescript library. I might be wrong, but I don't know if this is an issue with Parse Server, or if the typescript definitions need to be updated in that repo. |
OK so I will wait for the merge... |
I would imagine the fastest way of getting this feature on Typescript would be to submit a PR to the typescript library. |
Quicktip:
should do it. It's hacky, but works till the definition is up to date. |
Thank you fastrde, that's exactly what I did :D |
The problem is clearly an outdated definition file in the DefinitelyTyped Repository. I think this issue can be closed here. Maybe, at some point in the future, the definitions should be maintained here. |
I'm closing this as it does not seem to be a Parse Server issue. The solution seems to be to raise this issue in a 3rd part library. Feel free to comment if you have any questions and we can re-open this issue. |
New Issue Checklist
Issue Description
Hello,
I'm using Parse Server 4.4.0 and @types/parse 2.12.7 with TypeScript.
All is working as expected, thanks for your work :)
But, I'm trying to add a validation handler on a before save trigger, as described on the documentaion :
Parse.Cloud.beforeSave("Review", (request) => { // do any additional beforeSave logic here },{ fields: { stars : { required:true, options: stars => { return stars >= 1 && stars =< 5; }, error: 'Your review must be between one and five stars' } } });
But, in the index.d.ts used by Typescript, here is the declaration :
function beforeSave(arg1: any, func?: (request: BeforeSaveRequest) => Promise<void> | void): void;
And here is the JS code from your GitHub sources :
ParseCloud.beforeSave = function (parseClass, handler, validationHandler) {
As you can see, the "validationHandler" arguments for the method ParseCloud.beforeSave is missing in the declaration of the index.d.ts file. So, in Typescript, I can't add field validation like it's done in the documentation.
Am I missing somthing or is it really an issue ?
Thanks for help.
Steps to reproduce
Just install parse-server and @types/parse and use it with typescript.
Actual Outcome
In the index.d.ts :
function beforeSave(arg1: any, func?: (request: BeforeSaveRequest) => Promise<void> | void): void;
Expected Outcome
In the index.d.ts :
function beforeSave(arg1: any, func?: (request: BeforeSaveRequest) => Promise<void> | void, func?: (any) => Promise<void> | void): void;
Environment
Server
Database
Client
Logs
The text was updated successfully, but these errors were encountered: