nestjsx / crud

NestJs CRUD for RESTful APIs
https://github.com/nestjsx/crud/wiki
MIT License
4.04k stars 533 forks source link

PATCH failed with "an unknown value was passed to the validate function" #693

Closed OoDeLally closed 3 years ago

OoDeLally commented 3 years ago

I solve this issue after 4 hours of wall-head-banging and debugging, so I'm just posting it for the next guy who gets this issue.

When trying to PATCH a simple entity, I was getting the following error:

{
  "statusCode": 400,
  "message": [
    "an unknown value was passed to the validate function"
  ],
  "error": "Bad Request"
}

without any other form of explanation.

My problem was that I set up a global ValidationPipe at the root of my Nest app:

app.useGlobalPipes(
    new ValidationPipe({
      whitelist: true,
      forbidNonWhitelisted: true,
      transform: true,
      forbidUnknownValues: true,
    }),
  );

For some reason (nest noobie here), it doesnt play well with nestjsx/crude.

After removing it, it worked fine again.

jongomes commented 3 years ago

Mesmo problema

Verbunix commented 1 year ago

Just faced the same problem. Configuration of ValidationPipe has no effect. Solution was: