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

docs: mention ContextBuilder returned from #check() #972

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fedeci
Copy link
Member

@fedeci fedeci commented Jan 2, 2021

Description

We mention in the docs that ContextBuilder is exposed in the result of #check() middleware.

This allows to get the properties of the builder.
It can be used to create a library based on the context that will be built.
(e.g. swagger docs generation)

I don't know if it is better to expose the properties in this way or to build a "local" context, @gustavohenke what do you think?

To-do list

  • I have added tests for what I changed.
  • This pull request is ready to merge.

@coveralls
Copy link

coveralls commented Jan 2, 2021

Coverage Status

Coverage remained the same at 100.0% when pulling 939bae6 on fedeci:get-builder-properties into 690cd63 on express-validator:master.

Copy link
Member

@gustavohenke gustavohenke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it is better to expose the properties in this way or to build a "local" context

Hmm I don't mind either way at the moment. The Context interface is quite small, so this looks reasonable for now.

I don't recall if the .builder property is exposed/documented anywhere... do you think it would make more sense to put it in

export interface ContextHandler<Chain> {
bail(): Chain;
if(condition: CustomValidator | ValidationChain): Chain;
optional(options?: Partial<Optional> | true): Chain;
}
instead?

@fedeci
Copy link
Member Author

fedeci commented Jan 13, 2021

Yes, for example in check it is exposed here.
Maybe we should just document this so that the end user could create his own context with all his methods and not only access properties through the builder.

return Object.assign(
middleware,
bindAll(runner),
bindAll(new SanitizersImpl(builder, middleware as any)),
bindAll(new ValidatorsImpl(builder, middleware as any)),
bindAll(new ContextHandlerImpl(builder, middleware as any)),
{ builder },
);
}

@fedeci fedeci added the docs label Feb 23, 2021
@fedeci fedeci changed the title feat(context-builder): add 'getProperties' method docs: mention ContextBuilder returned from #check() Feb 23, 2021
Copy link
Member

@gustavohenke gustavohenke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will LGTM if we can add more docs than just this 😬

  • API entry
  • Possibly an entry under "Features", if it's necessary to showcase more of it

@fedeci fedeci requested a review from gustavohenke July 27, 2021 20:27
Copy link
Member

@gustavohenke gustavohenke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...did you want to address the previous review?

@fedeci
Copy link
Member Author

fedeci commented Aug 8, 2021

Oops nope, asked review for the wrong PR😄

@gustavohenke gustavohenke force-pushed the master branch 2 times, most recently from 3177f64 to 6e160b1 Compare April 7, 2023 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants