elysiajs / elysia

Ergonomic Framework for Humans
https://elysiajs.com
MIT License
10.59k stars 226 forks source link

Files Validation Schema Bug #812

Open Sly777 opened 2 months ago

Sly777 commented 2 months ago

What version of Elysia is running?

1.1.11

What platform is your computer?

Darwin 23.6.0 arm64 arm

What steps can reproduce the bug?

I added example below.


import { Elysia, t } from "elysia";

export const App = new Elysia({
  prefix: "/test",
})
  .get("/", () => {
    return "Hi everyone";
  })
  .post(
    "/postUrl",
    async ({ body: { images } }) => {
      console.log("images", images);
      if (images.length < 10) {
        throw new Error("it shouldn't come here.");
      }
      return images;
    },
    {
      body: t.Object({
        images: t.Files({
          type: ["image/jpeg"],
          minItems: 10,
          maxItems: 15,
          maxSize: "3m",
          minSize: "600k",
        }),
      }),
    }
  );

### What is the expected behavior?

It should follow `minItems`, `maxItems` checks.

### What do you see instead?

It just passes even if you send one file.

### Additional information

_No response_

### Have you try removing the `node_modules` and `bun.lockb` and try again yet?

not related