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

feat(checkSchema): run imperatively #977

Merged
merged 3 commits into from Jan 9, 2021

Conversation

fedeci
Copy link
Member

@fedeci fedeci commented Jan 6, 2021

Description

Closes #822

To-do list

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

@coveralls
Copy link

coveralls commented Jan 6, 2021

Coverage Status

Coverage remained the same at 100.0% when pulling 03caae7 on fedeci:imperatively-check-schema into dae1bb8 on express-validator:master.

},
});

expect(schema.run(req)).resolves;
Copy link
Member

Choose a reason for hiding this comment

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

this needs an await or return -- otherwise it may fail out of band

Copy link
Member Author

Choose a reason for hiding this comment

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

I forgot the return🤦🏻‍♂️

@@ -59,7 +59,7 @@ const validLocations: Location[] = ['body', 'cookies', 'headers', 'params', 'que
const protectedNames = ['errorMessage', 'in'];

export function checkSchema(schema: Schema, defaultLocations: Location[] = validLocations) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we provide a custom type here?
E.g.

ValidationChain[] & { run(req: Request): Promise<unknown> }

@fedeci fedeci merged commit 7f15d2d into express-validator:master Jan 9, 2021
@fedeci fedeci deleted the imperatively-check-schema branch January 9, 2021 12:40
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.

oneOf and checkSchema cannot easily be run imperatively.
3 participants