Skip to content

[Bug]: File type doesn't work in validation for next-safe-action (Next Server Actions) #439

@foopis23

Description

@foopis23

Which packages are impacted?

  • @rvf/react
  • @rvf/react-router
  • @rvf/zod
  • @rvf/yup
  • zod-form-data

What version of these packages are you using?

  • "zod-form-data": "^2.0.7",
  • "next-safe-action": "^7.10.6",
  • "next": "15.2.3",

Please provide a link to a minimal reproduction of the issue.

https://github.com/foopis23/zfd-server-action-file-validation

Steps to Reproduce the Bug or Issue

  1. Run Application
  2. Go to http://localhost:3000
  3. Select files to upload
  4. Hit submit button
  5. See validation errors

Expected behavior

I expected validation to pass when files were uploaded. They are coming in as an array of file instances so i don't know why its failing.

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Arc
  • Version: 135.0.7049.116 (Official Build) (arm64)

Additional context

The two important files are:
src/app/page.tsx
src/server-actions/submit.ts

I implemented a non working (using zfd) and working version of the server action. For the working version i just made a custom zod type that worked the way i expected zfd.file() to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions