Skip to content
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

Fix: handling verify function edge case #61

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rafayeljamalyan
Copy link

If the verify function is created using rest params, the length of that function (arity) will be 0, so we need to handle that case.
I faced this issue when using this package along with Nest.JS, where verify callback is created using rest params.

...
const callback = (...params) => __awaiter(this, void 0, void 0, function* () {
const done = params[params.length - 1];
    try {
        const validateResult = yield this.validate(...params);  /* here this.validate is our verify callback */
        if (Array.isArray(validateResult)) {
            done(null, ...validateResult);
        }
        else {
            done(null, validateResult);
        }
    }
    catch (err) {
        done(err, null);
    }
});
            ...

If the verify function is created using rest params, the length of that function (arity) will be 0, so we need to handle that case
Fix: handling verify function edge case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant