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

Joi resolver crashes on File validation #668

Closed
romanstetsyk opened this issue Mar 21, 2024 · 1 comment
Closed

Joi resolver crashes on File validation #668

romanstetsyk opened this issue Mar 21, 2024 · 1 comment

Comments

@romanstetsyk
Copy link

Describe the bug
The validator crashed while trying to validate a File upload with an error Cannot read properties of undefined (reading 'length') .
The schema like this works fine:

const file = Joi.object<File>().label("File");

But as soon as I try to add the fields to validate it crashes.

const file = Joi.object<File>({
  name: Joi.string().max(255).required(),
}).label("File");

To Reproduce
Steps to reproduce the behavior:

  1. Go to the codesandbox below
  2. Drag any file to the upload area
  3. Click 'submit'
  4. See error

Codesandbox link (Required)

https://codesandbox.io/p/sandbox/joi-error-hcktkx?file=%2Fsrc%2FApp.tsx%3A19%2C42

Expected behavior
Such an error should not appear.

Screenshots
image

Desktop (please complete the following information):

  • OS: macOS
  • Browser chrome
  • Version 123
@jorisre
Copy link
Member

jorisre commented Jul 3, 2024

This isn't a resolver issue, but a Joi issue. As I'm not familiar with Joi, I can't help you with using Joi validation for File uploads. The error you're seeing is a TypeError: Illegal invocation.

Screenshot 2024-07-03 at 10 34 28

@jorisre jorisre closed this as completed Jul 3, 2024
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

2 participants