Hi, first of all thanks for really great library.
Is there any way to turn off request payload validation? I would like to have more control around this and handle validation by myself.
Best,
Jakub
After short investigation I found that it should be possible by adding something like that:
{{#if !disableValidation}} ... {{/if}} to remove getValidatedArgs declaration and call
in
tsoa/src/routeGeneration/templates/express.ts
tsoa/src/routeGeneration/templates/hapi.ts
tsoa/src/routeGeneration/templates/koa.ts
@lukeautry, let me know what do you think about this.
I was thinking about this, too.
What you really want is s custom error when the problem occures.
E.g. maxLength 20 -> you want a custom error for this.
Maybe we can do this with jsdoc?
Maybe this can be handled with validators, but in your case @jakubzloczewski , it sounds like you should want to completely skip validation. I think that's a reasonable use case.
Ahhh, I forgot to say something about my walk around.
At this point I don't have errors well documented in swagger file but it is sufficient for me. I guess it could be done somehow with @DefaultResponse decorator.
@egandro you can achieve this with turning off validation and validate request body with Joi. You have to keep in sync Joi schemas with types of request objects - It's not perfect but in works.
So what you want is not "no validation".
What you want are custom errors :) Thats's a whole different story!
Yes - I love this idea - but ... it should be possible to have internationalisation - and this is related to the JWT / Security system (which is application dependant).
So we should make this customizable.
@jakubzloczewski since your custom template is working for you, I'm going to close this issue. If someone else would like this feature, they're welcome to comment again and we can consider reopening the issue. But to be honest, having the validation is most of the reason why tsoa exists. So to turn off the validation seems rather strange.
Most helpful comment
Ahhh, I forgot to say something about my walk around.
At this point I don't have errors well documented in swagger file but it is sufficient for me. I guess it could be done somehow with @DefaultResponse decorator.
@egandro you can achieve this with turning off validation and validate request body with Joi. You have to keep in sync Joi schemas with types of request objects - It's not perfect but in works.