diff --git a/README.md b/README.md index eacc3f51b..fc5beab6c 100644 --- a/README.md +++ b/README.md @@ -47,8 +47,9 @@ Start your API server with I/O schema validation and custom middlewares in minut 19. [Generating a Frontend Client](#generating-a-frontend-client) 20. [Creating a documentation](#creating-a-documentation) 21. [Tagging the endpoints](#tagging-the-endpoints) -5. [Additional hints](#additional-hints) - 1. [How to test endpoints](#how-to-test-endpoints) + 22. [How to test endpoints](#how-to-test-endpoints) +5. [Caveats](#caveats) + 1. [Coercive schema of Zod](#coercive-schema-of-zod) 2. [Excessive properties in endpoint output](#excessive-properties-in-endpoint-output) 6. [Your input to my output](#your-input-to-my-output) @@ -918,8 +919,6 @@ const exampleEndpoint = taggedEndpointsFactory.build({ }); ``` -# Additional hints - ## How to test endpoints The way to test endpoints is to mock the request, response, and logger objects, invoke the `execute()` method, and @@ -950,6 +949,21 @@ test("should respond successfully", async () => { _This method is optimized for the `defaultResultHandler`. With the flexibility to customize, you can add additional properties as needed._ +# Caveats + +There are some well-known issue and limitations, or third party bugs that cannot be fixed in the usual way, but you +should be aware of them. + +## Coercive schema of Zod + +Despite being supported by the library, `z.coerce.*` schema +[does not work intuitively](https://github.com/RobinTail/express-zod-api/issues/759). +Please be aware that `z.coerce.number()` and `z.number({ coerce: true })` (being typed not well) still will NOT allow +you to assign anything but number. Moreover, coercive schemas are not fail-safe and their methods `.isOptional()` and +`.isNullable()` [are buggy](https://github.com/colinhacks/zod/issues/1911). If possible, try to avoid using this type +of schemas. This issue [will NOT be fixed](https://github.com/colinhacks/zod/issues/1760#issuecomment-1407816838) in +Zod version 3.x. + ## Excessive properties in endpoint output The schema validator removes excessive properties by default. However, Typescript