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

Adding custom matchedData within .custom() #806

Closed
ghost opened this issue Dec 3, 2019 · 1 comment
Closed

Adding custom matchedData within .custom() #806

ghost opened this issue Dec 3, 2019 · 1 comment

Comments

@ghost
Copy link

ghost commented Dec 3, 2019

I would like to set other fields as matched data for retrieval later on when calling matchedData().
Is this possible?

e.g. (partial pseudo code)

body('user', ErrorCode.LIBRARY_USER_INVALID).isMongoId().custom((value, { req }) => {
  const user = mongoose.loadUserById(value);;

  // now set userType as a matched field so that this will be returned when calling matchedData(req)
  setAsMatchedData('userType',  user.type);
});
@ghost ghost changed the title Adding custom matchedData within a .custom() Adding custom matchedData within .custom() Dec 3, 2019
@gustavohenke
Copy link
Member

I'll consider this as an equivalent of the rename feature, which some users have been asking about. #785

@gustavohenke gustavohenke closed this as not planned Won't fix, can't repro, duplicate, stale Apr 13, 2023
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

No branches or pull requests

1 participant