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

add callback in invokeBefore to stop the function. #9

Open
AhmedElwerdany opened this issue Mar 18, 2022 · 0 comments
Open

add callback in invokeBefore to stop the function. #9

AhmedElwerdany opened this issue Mar 18, 2022 · 0 comments
Labels
enhancement New feature or request feature

Comments

@AhmedElwerdany
Copy link
Owner

Is your feature request related to a problem? Please describe.
A good usage of invokeBefore is validations, but it's hard to do it, since I can't stop the functions from running by invoking a function or returning a specific value

Describe the solution you'd like
A callback passed to invokeBefore, that when invoked it stops the function from going to the original method.

invokeBeforeCreateUser(name, next) {
  if(!name) {
     // this should throw an error, stops the hook from going to the target method. 
     next(new Error('please enter your name'))
  }
  
  // this should pass the control to the target method
  next()
}

Describe alternatives you've considered
None
Additional context
None

@AhmedElwerdany AhmedElwerdany added enhancement New feature or request feature labels Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature
Projects
None yet
Development

No branches or pull requests

1 participant