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

transformParameters & normalizeParameters #10

Open
L1lith opened this issue Aug 29, 2018 · 1 comment
Open

transformParameters & normalizeParameters #10

L1lith opened this issue Aug 29, 2018 · 1 comment
Labels
enhancement New feature or request

Comments

@L1lith
Copy link

L1lith commented Aug 29, 2018

TransformParameters:
Allows you to modify your parameters after they are sanitized before they are passed to call. It could accept either the synchronous return, a promise to await to the output, or the call of a provided callback. It would merge the returned value with the existing ones. This could be useful for something like this

transformParameters: (parameters, next) => {
     bcrypt.hash(parameters.password, (error, hash) =>{
          if (error) return next(error)
          next({hash})
     })
}

NormalizeParameters
Almost exactly the same as transformParameters except it would happen before sanitation so you could normalize it before it's sanitized.

normalizeParameters: parameters => ({email: parameters.email.toLowerCase()})
@Talha-T
Copy link
Owner

Talha-T commented Aug 29, 2018

Very nice ideas, I appreciate it.

@Talha-T Talha-T added the enhancement New feature or request label Aug 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants