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

Using oneOf together with checkExact causes Unknown Field errors #1269

Open
Ansis100 opened this issue Jan 5, 2024 · 2 comments · May be fixed by #1282
Open

Using oneOf together with checkExact causes Unknown Field errors #1269

Ansis100 opened this issue Jan 5, 2024 · 2 comments · May be fixed by #1282
Assignees

Comments

@Ansis100
Copy link

Ansis100 commented Jan 5, 2024

Describe the bug

When oneOf is used together with checkExact, the fields specified inside oneOf are not recognized.

To Reproduce

  1. Create both normal validation chains and chains inside a oneOf array.
  2. Add checkExact as the last validation chain.
  3. Send a request that contains fields contained in the oneOf array.

https://runkit.com/ansis100/6597bf964216370008d1c1c6

Expected behavior

All the fields contained in oneOf are recognized by checkExact as allowed fields.

Current behavior

checkExact returns an Unknown field error for any fields contained in oneOf.

Environment:

  • Express-validator version: 7.0.1
  • Express version: 4.18.1
  • Node.js version: 16.14.0
@Ansis100
Copy link
Author

Ansis100 commented Jan 5, 2024

I think a contributing factor is the fact that there is no easy way to set a validation chain to be isFoo() or isBar(), you have to define separate chains for each case using oneOf. But that's a topic for a different issue.

@fedeci
Copy link
Member

fedeci commented Feb 21, 2024

oneOf is currently unsupported with checkExact. If it is easily implementable I'll do it right now.

@fedeci fedeci self-assigned this Feb 21, 2024
@fedeci fedeci linked a pull request Feb 22, 2024 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants