Skip to content

Add parameters : for exemple to disable forbidden 4XX #3

@giraudvalentin

Description

@giraudvalentin

Hi

I was using your lib for two things :

  • Clarify errors in validation as well for client or server side.
  • Make additionalProperties: false working by send an error to server side when result contain not declared fields in schemas

So, it work absolutely, BUT this lib do other things that i dont want.

  • Add a stacktrace to validation error (not wanted)
  • Refuse to send HTTP 4XX (only 500), Return 500 instead of a 422 due to :
    // No validator, it means the HTTP status is not allowed
    const validator = validators[statusCode]

    if (!validator) {
      throw createError(StatusCodes.INTERNAL_SERVER_ERROR, validationMessagesFormatters.invalidResponseCode(statusCode))
    }

(this is due to the fact that i only declare 200 in schema, but no other http code, so may be the option is to only validate 200 for response ?)

I have tried to reimplement theses point by using hook but it add a lot of code.

I am thinking of forking this library to delete all theses features i didn't want, but think it may be cool if you add configurations parameters to the lib for this.

To sum up, i only want clear error object and respect of additionalProperties (or error), for the rest of features i didn't need, i just want an option for disable it.

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions