samchon / nestia

NestJS Helper Libraries + TypeScript OpenAPI generator
https://nestia.io/
MIT License
1.71k stars 89 forks source link

Typed Route with assertEquals #875

Closed soumilbaldota closed 3 months ago

soumilbaldota commented 3 months ago

I am attempting to use TypedRoute with assertEqual instead of the default assert in a Nest.js application. I need a more complete list of errors and what was wrong in the body of the response compared to my schema. It seems that there is no typia.assertEqualsStringify() function available in typia.

How can I successfully achieve this? with some workaround? Thank you.

surya-maximl commented 3 months ago

Thanks for raising this, @soumilbaldota. Coincidentally, I am facing the same issue

samchon commented 3 months ago

Well, the typia.json.assertStringify() function does not serialize surplus properties that are not registered in the TypeScript type.

Is there any special reason that you need the typia.json.assertEqualStringify() function?

soumilbaldota commented 3 months ago

@samchon I am using a library that gives somewhat polymorphic responses based on the input but may have some data that I don't want the clients to receive. Hence I want to validate if there are any extra properties, I want to throw acceptable errors when encountering such things.

samchon commented 3 months ago

I repeat that, @TypedRoute() makes client not to receive any surplur properties.

@TypedRoute converts to only explicitly typed properties in the DTO structure.